home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / emacssrc.zip / EMACSSRC.TAR / emacs-19.17 / lisp / dunnet.el < prev    next >
Lisp/Scheme  |  1993-07-13  |  113KB  |  3,329 lines

  1. ;;; dunnet.el --- Text adventure for Emacs
  2.  
  3. ;; Author: Ron Schnell <ronnie@media.mit.edu>
  4. ;; Created: 25 Jul 1992
  5. ;; Version: 2.0
  6. ;; Keywords: games
  7. ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
  8.  
  9. ;; This file is part of GNU Emacs.
  10.  
  11. ;; GNU Emacs is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;; GNU General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  23. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. ;;; Commentary:
  26.  
  27. ;; This game can be run in batch mode.  To do this, use:
  28. ;;    emacs -batch -l dunnet
  29.  
  30. ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
  31. ;;;  The log file should be set for your system, and it must
  32. ;;;  be writeable by all.
  33.  
  34.  
  35.       (defvar dun-log-file "/usr/local/dunnet.score"
  36.     "Name of file to store score information for dunnet.")
  37.  
  38. (if nil
  39.     (eval-and-compile (setq byte-compile-warnings nil)))
  40.  
  41. (require 'cl)
  42.  
  43. ;;;; Mode definitions for interactive mode
  44.  
  45. (defun dun-mode ()
  46.   "Major mode for running dunnet."
  47.   (interactive)
  48.   (text-mode)
  49.   (use-local-map dungeon-mode-map)
  50.   (setq major-mode 'dungeon-mode)
  51.   (setq mode-name "Dungeon"))
  52.  
  53. (defun dun-parse (arg)
  54.   "Function called when return is pressed in interactive mode to parse line."
  55.   (interactive "*p")
  56.   (beginning-of-line)
  57.   (setq beg (+ (point) 1))
  58.   (end-of-line)
  59.   (if (and (not (= beg (point))) (not (< (point) beg))
  60.        (string= ">" (buffer-substring (- beg 1) beg)))
  61.       (progn
  62.     (setq line (downcase (buffer-substring beg (point))))
  63.     (princ line)
  64.     (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
  65.         (dun-mprinc "I don't understand that.\n")))
  66.     (goto-char (point-max))
  67.     (dun-mprinc "\n"))
  68.     (dun-messages))
  69.     
  70. (defun dun-messages ()
  71.   (if dun-dead
  72.       (text-mode)
  73.     (if (eq dungeon-mode 'dungeon)
  74.     (progn
  75.       (if (not (= room dun-current-room))
  76.           (progn
  77.         (dun-describe-room dun-current-room)
  78.         (setq room dun-current-room)))
  79.       (dun-fix-screen)
  80.       (dun-mprinc ">")))))
  81.  
  82.  
  83. ;;;###autoload
  84. (defun dunnet ()
  85.   "Switch to *dungeon* buffer and start game."
  86.   (interactive)
  87.   (switch-to-buffer "*dungeon*")
  88.   (dun-mode)
  89.   (setq dun-dead nil)
  90.   (setq room 0)
  91.   (dun-messages))
  92.  
  93. ;;;;
  94. ;;;; This section contains all of the verbs and commands.
  95. ;;;;
  96.  
  97. ;;; Give long description of room if haven't been there yet.  Otherwise
  98. ;;; short.  Also give long if we were called with negative room number.
  99.  
  100. (defun dun-describe-room (room)
  101.   (if (and (not (member (abs room) dun-light-rooms)) 
  102.        (not (member obj-lamp dun-inventory)))
  103.       (dun-mprincl "It is pitch dark.  You are likely to be eaten by a grue.")
  104.     (dun-mprincl (cadr (nth (abs room) dun-rooms)))
  105.     (if (and (and (or (member room dun-visited) 
  106.               (string= dun-mode "dun-superb")) (> room 0))
  107.          (not (string= dun-mode "long")))
  108.     nil
  109.       (dun-mprinc (car (nth (abs room) dun-rooms)))
  110.     (dun-mprinc "\n"))
  111.     (if (not (string= dun-mode "long"))
  112.     (if (not (member (abs room) dun-visited))
  113.         (setq dun-visited (append (list (abs room)) dun-visited))))
  114.     (dolist (xobjs (nth dun-current-room dun-room-objects))
  115.       (if (= xobjs obj-special)
  116.       (dun-special-object)
  117.     (if (>= xobjs 0)
  118.         (dun-mprincl (car (nth xobjs dun-objects)))
  119.       (if (not (and (= xobjs obj-bus) dun-inbus))
  120.           (progn
  121.         (dun-mprincl (car (nth (abs xobjs) dun-perm-objects)))))))
  122.       (if (and (= xobjs obj-jar) dun-jar)
  123.       (progn
  124.         (dun-mprincl "The jar contains:")
  125.         (dolist (x dun-jar)
  126.           (dun-mprinc "     ")
  127.           (dun-mprincl (car (nth x dun-objects)))))))
  128.     (if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus)
  129.     (dun-mprincl "You are on the bus."))))
  130.  
  131. ;;; There is a special object in the room.  This object's description,
  132. ;;; or lack thereof, depends on certain conditions.
  133.  
  134. (defun dun-special-object ()
  135.  
  136.   (if (= dun-current-room computer-room)
  137.       (if dun-computer
  138.       (dun-mprincl 
  139. "The panel lights are flashing in a seemingly organized pattern.")
  140.     (dun-mprincl "The panel lights are steady and motionless.")))
  141.  
  142.   (if (and (= dun-current-room red-room) 
  143.        (not (member obj-towel (nth red-room dun-room-objects))))
  144.       (dun-mprincl "There is a hole in the floor here."))
  145.  
  146.   (if (and (= dun-current-room marine-life-area) dun-black)
  147.       (dun-mprincl 
  148. "The room is lit by a black light, causing the fish, and some of 
  149. your objects, to give off an eerie glow."))
  150.   (if (and (= dun-current-room fourth-vermont-intersection) dun-hole)
  151.       (progn
  152.     (dun-mprincl"You fall into a hole in the ground.")
  153.     (setq dun-current-room vermont-station)
  154.     (dun-describe-room vermont-station)))
  155.  
  156.   (if (> dun-current-room endgame-computer-room)
  157.       (progn
  158.     (if (not dun-correct-answer)
  159.         (dun-endgame-question)
  160.       (dun-mprincl "Your question is:")
  161.       (dun-mprincl dun-endgame-question))))
  162.  
  163.   (if (= dun-current-room sauna)
  164.       (progn
  165.     (dun-mprincl (nth dun-sauna-level '(
  166. "It is normal room temperature in here."
  167. "It is luke warm in here."
  168. "It is comfortably hot in here."
  169. "It is refreshingly hot in here."
  170. "You are dead now.")))
  171.     (if (and (= dun-sauna-level 3) 
  172.          (or (member obj-rms dun-inventory)
  173.              (member obj-rms (nth dun-current-room dun-room-objects))))
  174.         (progn
  175.           (dun-mprincl 
  176. "You notice the wax on your statuette beginning to melt, until it completely
  177. melts off.  You are left with a beautiful diamond!")
  178.           (if (member obj-rms dun-inventory)
  179.           (progn
  180.             (dun-remove-obj-from-inven obj-rms)
  181.             (setq dun-inventory (append dun-inventory 
  182.                         (list obj-diamond))))
  183.         (dun-remove-obj-from-room dun-current-room obj-rms)
  184.         (dun-replace dun-room-objects dun-current-room
  185.              (append (nth dun-current-room dun-room-objects)
  186.                  (list obj-diamond))))
  187.           (if (member obj-floppy dun-inventory)
  188.           (progn
  189.             (dun-mprincl
  190. "You notice your floppy disk beginning to melt.  As you grab for it, the 
  191. disk bursts into flames, and disintegrates.")
  192.             (dun-remove-obj-from-inven obj-floppy)
  193.             (dun-remove-obj-from-room dun-current-room obj-floppy)))))
  194.     )))
  195.  
  196. (defun dun-die (murderer)
  197.   (dun-mprinc "\n")
  198.   (if murderer
  199.       (dun-mprincl "You are dead."))
  200.   (dun-do-logfile 'dun-die murderer)
  201.   (dun-score nil)
  202.   (setq dun-dead t))
  203.  
  204. (defun dun-quit (args)
  205.   (dun-die nil))
  206.  
  207. ;;; Print every object in player's inventory.  Special case for the jar,
  208. ;;; as we must also print what is in it.
  209.  
  210. (defun dun-inven (args)
  211.   (dun-mprinc "You currently have:")
  212.   (dun-mprinc "\n")
  213.   (dolist (curobj dun-inventory)
  214.     (if curobj
  215.     (progn
  216.       (dun-mprincl (cadr (nth curobj dun-objects)))
  217.       (if (and (= curobj obj-jar) dun-jar)
  218.           (progn
  219.         (dun-mprincl "The jar contains:")
  220.         (dolist (x dun-jar)
  221.           (dun-mprinc "     ")
  222.           (dun-mprincl (cadr (nth x dun-objects))))))))))
  223.  
  224. (defun dun-shake (obj)
  225.   (let (objnum)
  226.     (when (setq objnum (dun-objnum-from-args-std obj))
  227.       (if (member objnum dun-inventory)
  228.       (progn
  229. ;;;    If shaking anything will do anything, put here.
  230.         (dun-mprinc "Shaking ")
  231.         (dun-mprinc (downcase (cadr (nth objnum dun-objects))))
  232.         (dun-mprinc " seems to have no effect.")
  233.         (dun-mprinc "\n")
  234.         )
  235.     (if (and (not (member objnum (nth dun-current-room dun-room-silents)))
  236.          (not (member objnum (nth dun-current-room dun-room-objects))))
  237.         (dun-mprincl "I don't see that here.")
  238. ;;;     Shaking trees can be deadly
  239.       (if (= objnum obj-tree)
  240.           (progn
  241.         (dun-mprinc
  242.  "You begin to shake a tree, and notice a coconut begin to fall from the air.
  243. As you try to get your hand up to block it, you feel the impact as it lands
  244. on your head.")
  245.         (dun-die "a coconut"))
  246.         (if (= objnum obj-bear)
  247.         (progn
  248.           (dun-mprinc
  249. "As you go up to the bear, it removes your head and places it on the ground.")
  250.           (dun-die "a bear"))
  251.           (if (< objnum 0)
  252.           (dun-mprincl "You cannot shake that.")
  253.         (dun-mprincl "You don't have that.")))))))))
  254.  
  255.  
  256. (defun dun-drop (obj)
  257.   (if dun-inbus
  258.       (dun-mprincl "You can't drop anything while on the bus.")
  259.   (let (objnum ptr)
  260.     (when (setq objnum (dun-objnum-from-args-std obj))
  261.       (if (not (setq ptr (member objnum dun-inventory)))
  262.       (dun-mprincl "You don't have that.")
  263.     (progn
  264.       (dun-remove-obj-from-inven objnum)
  265.       (dun-replace dun-room-objects dun-current-room
  266.            (append (nth dun-current-room dun-room-objects)
  267.                (list objnum)))
  268.       (dun-mprincl "Done.")
  269.       (if (member objnum (list obj-food obj-weight obj-jar))
  270.           (dun-drop-check objnum))))))))
  271.  
  272. ;;; Dropping certain things causes things to happen.
  273.  
  274. (defun dun-drop-check (objnum)
  275.   (if (and (= objnum obj-food) (= room bear-hangout)
  276.        (member obj-bear (nth bear-hangout dun-room-objects)))
  277.       (progn
  278.     (dun-mprincl
  279. "The bear takes the food and runs away with it. He left something behind.")
  280.     (dun-remove-obj-from-room dun-current-room obj-bear)
  281.     (dun-remove-obj-from-room dun-current-room obj-food)
  282.     (dun-replace dun-room-objects dun-current-room
  283.          (append (nth dun-current-room dun-room-objects)
  284.              (list obj-key)))))
  285.  
  286.   (if (and (= objnum obj-jar) (member obj-nitric dun-jar) 
  287.        (member obj-glycerine dun-jar))
  288.       (progn
  289.     (dun-mprincl 
  290.      "As the jar impacts the ground it explodes into many pieces.")
  291.     (setq dun-jar nil)
  292.     (dun-remove-obj-from-room dun-current-room obj-jar)
  293.     (if (= dun-current-room fourth-vermont-intersection)
  294.         (progn
  295.           (setq dun-hole t)
  296.           (setq dun-current-room vermont-station)
  297.           (dun-mprincl 
  298. "The explosion causes a hole to open up in the ground, which you fall
  299. through.")))))
  300.  
  301.   (if (and (= objnum obj-weight) (= dun-current-room maze-button-room))
  302.       (dun-mprincl "A passageway opens.")))
  303.  
  304. ;;; Give long description of current room, or an object.
  305.       
  306. (defun dun-examine (obj)
  307.   (let (objnum)
  308.     (setq objnum (dun-objnum-from-args obj))
  309.     (if (eq objnum obj-special)
  310.     (dun-describe-room (* dun-current-room -1))
  311.       (if (and (eq objnum obj-computer)
  312.            (member obj-pc (nth dun-current-room dun-room-silents)))
  313.       (dun-examine '("pc"))
  314.     (if (eq objnum nil)
  315.         (dun-mprincl "I don't know what that is.")
  316.       (if (and (not (member objnum 
  317.                 (nth dun-current-room dun-room-objects)))
  318.            (not (member objnum 
  319.                 (nth dun-current-room dun-room-silents)))
  320.            (not (member objnum dun-inventory)))
  321.           (dun-mprincl "I don't see that here.")
  322.         (if (>= objnum 0)
  323.         (if (and (= objnum obj-bone) 
  324.              (= dun-current-room marine-life-area) dun-black)
  325.             (dun-mprincl 
  326. "In this light you can see some writing on the bone.  It says:
  327. For an explosive time, go to Fourth St. and Vermont.")
  328.           (if (nth objnum dun-physobj-desc)
  329.               (dun-mprincl (nth objnum dun-physobj-desc))
  330.             (dun-mprincl "I see nothing special about that.")))
  331.           (if (nth (abs objnum) dun-permobj-desc)
  332.           (progn
  333.             (dun-mprincl (nth (abs objnum) dun-permobj-desc)))
  334.         (dun-mprincl "I see nothing special about that.")))))))))
  335.  
  336. (defun dun-take (obj)
  337.   (if dun-inbus
  338.       (dun-mprincl "You can't take anything while on the bus.")
  339.   (setq obj (dun-firstword obj))
  340.   (if (not obj)
  341.       (dun-mprincl "You must supply an object.")
  342.     (if (string= obj "all")
  343.     (let (gotsome)
  344.       (setq gotsome nil)
  345.       (dolist (x (nth dun-current-room dun-room-objects))
  346.         (if (and (>= x 0) (not (= x obj-special)))
  347.         (progn
  348.           (setq gotsome t)
  349.           (dun-mprinc (cadr (nth x dun-objects)))
  350.           (dun-mprinc ": ")
  351.           (dun-take-object x))))
  352.       (if (not gotsome)
  353.           (dun-mprincl "Nothing to take.")))
  354.       (let (objnum)
  355.     (setq objnum (cdr (assq (intern obj) dun-objnames)))
  356.     (if (eq objnum nil)
  357.         (progn
  358.           (dun-mprinc "I don't know what that is.")
  359.           (dun-mprinc "\n"))
  360.       (dun-take-object objnum)))))))
  361.  
  362. (defun dun-take-object (objnum)
  363.   (if (and (member objnum dun-jar) (member obj-jar dun-inventory))
  364.       (let (newjar)
  365.     (dun-mprincl "You remove it from the jar.")
  366.     (setq newjar nil)
  367.     (dolist (x dun-jar)
  368.       (if (not (= x objnum))
  369.           (setq newjar (append newjar (list x)))))
  370.     (setq dun-jar newjar)
  371.     (setq dun-inventory (append dun-inventory (list objnum))))
  372.     (if (not (member objnum (nth dun-current-room dun-room-objects)))
  373.     (if (not (member objnum (nth dun-current-room dun-room-silents)))
  374.         (dun-mprinc "I do not see that here.")
  375.       (dun-try-take objnum))
  376.       (if (>= objnum 0)
  377.       (progn
  378.         (if (and (car dun-inventory) 
  379.              (> (+ (dun-inven-weight) (nth objnum dun-object-lbs)) 11))
  380.         (dun-mprinc "Your load would be too heavy.")
  381.           (setq dun-inventory (append dun-inventory (list objnum)))
  382.           (dun-remove-obj-from-room dun-current-room objnum)
  383.           (dun-mprinc "Taken.  ")
  384.           (if (and (= objnum obj-towel) (= dun-current-room red-room))
  385.           (dun-mprinc 
  386.            "Taking the towel reveals a hole in the floor."))))
  387.     (dun-try-take objnum)))
  388.     (dun-mprinc "\n")))
  389.  
  390. (defun dun-inven-weight ()
  391.   (let (total)
  392.     (setq total 0)
  393.     (dolist (x dun-jar)
  394.       (setq total (+ total (nth x dun-object-lbs))))
  395.     (dolist (x dun-inventory)
  396.       (setq total (+ total (nth x dun-object-lbs)))) total))
  397.  
  398. ;;; We try to take an object that is untakable.  Print a message
  399. ;;; depending on what it is.
  400.  
  401. (defun dun-try-take (obj)
  402.   (dun-mprinc "You cannot take that."))
  403.  
  404. (defun dun-dig (args)
  405.   (if dun-inbus
  406.       (dun-mprincl "You can't dig while on the bus.")
  407.   (if (not (member 0 dun-inventory))
  408.       (dun-mprincl "You have nothing with which to dig.")
  409.     (if (not (nth dun-current-room dun-diggables))
  410.     (dun-mprincl "Digging here reveals nothing.")
  411.       (dun-mprincl "I think you found something.")
  412.       (dun-replace dun-room-objects dun-current-room
  413.            (append (nth dun-current-room dun-room-objects)
  414.                (nth dun-current-room dun-diggables)))
  415.       (dun-replace dun-diggables dun-current-room nil)))))
  416.  
  417. (defun dun-climb (obj)
  418.   (let (objnum)
  419.     (setq objnum (dun-objnum-from-args obj))
  420.     (if (and (not (= objnum obj-special))
  421.          (not (member objnum (nth dun-current-room dun-room-objects)))
  422.          (not (member objnum (nth dun-current-room dun-room-silents)))
  423.          (not (member objnum dun-inventory)))
  424.     (dun-mprincl "I don't see that here.")
  425.       (if (and (= objnum obj-special)
  426.            (not (member obj-tree (nth dun-current-room dun-room-silents))))
  427.       (dun-mprincl "There is nothing here to climb.")
  428.     (if (and (not (= objnum obj-tree)) (not (= objnum obj-special)))
  429.         (dun-mprincl "You can't climb that.")
  430.       (dun-mprincl
  431. "You manage to get about two feet up the tree and fall back down.  You
  432. notice that the tree is very unsteady."))))))
  433.  
  434. (defun dun-eat (obj)
  435.   (let (objnum)
  436.     (when (setq objnum (dun-objnum-from-args-std obj))
  437.       (if (not (member objnum dun-inventory))
  438.       (dun-mprincl "You don't have that.")
  439.     (if (not (= objnum obj-food))
  440.         (progn
  441.           (dun-mprinc "You forcefully shove ")
  442.           (dun-mprinc (downcase (cadr (nth objnum dun-objects))))
  443.           (dun-mprincl " down your throat, and start choking.")
  444.           (dun-die "choking"))
  445.       (dun-mprincl "That tasted horrible.")
  446.       (dun-remove-obj-from-inven obj-food))))))
  447.  
  448. (defun dun-put (args)
  449.   (if dun-inbus
  450.       (dun-mprincl "You can't do that while on the bus")
  451.     (let (newargs objnum objnum2 obj)
  452.       (setq newargs (dun-firstwordl args))
  453.       (if (not newargs)
  454.       (dun-mprincl "You must supply an object")
  455.     (setq obj (intern (car newargs)))
  456.     (setq objnum (cdr (assq obj dun-objnames)))
  457.     (if (not objnum)
  458.         (dun-mprincl "I don't know what that object is.")
  459.       (if (not (member objnum dun-inventory))
  460.           (dun-mprincl "You don't have that.")
  461.         (setq newargs (dun-firstwordl (cdr newargs)))
  462.         (setq newargs (dun-firstwordl (cdr newargs)))
  463.         (if (not newargs)
  464.         (dun-mprincl "You must supply an indirect object.")
  465.           (setq objnum2 (cdr (assq (intern (car newargs)) dun-objnames)))
  466.           (if (and (eq objnum2 obj-computer) (= dun-current-room pc-area))
  467.           (setq objnum2 obj-pc))
  468.           (if (not objnum2)
  469.           (dun-mprincl "I don't know what that indirect object is.")
  470.         (if (and (not (member objnum2 
  471.                       (nth dun-current-room dun-room-objects)))
  472.              (not (member objnum2 
  473.                       (nth dun-current-room dun-room-silents)))
  474.              (not (member objnum2 dun-inventory)))
  475.             (dun-mprincl "That indirect object is not here.")
  476.           (dun-put-objs objnum objnum2))))))))))
  477.  
  478. (defun dun-put-objs (obj1 obj2)
  479.   (if (and (= obj2 obj-drop) (not dun-nomail))
  480.       (setq obj2 obj-chute))
  481.  
  482.   (if (= obj2 obj-disposal) (setq obj2 obj-chute))
  483.  
  484.   (if (and (= obj1 obj-cpu) (= obj2 obj-computer))
  485.       (progn
  486.     (dun-remove-obj-from-inven obj-cpu)
  487.     (setq dun-computer t)
  488.     (dun-mprincl
  489. "As you put the CPU board in the computer, it immediately springs to life.
  490. The lights start flashing, and the fans seem to startup."))
  491.     (if (and (= obj1 obj-weight) (= obj2 obj-button))
  492.     (dun-drop '("weight"))
  493.       (if (= obj2 obj-jar)                 ;; Put something in jar
  494.       (if (not (member obj1 (list obj-paper obj-diamond obj-emerald
  495.                       obj-license obj-coins obj-egg
  496.                       obj-nitric obj-glycerine)))
  497.           (dun-mprincl "That will not fit in the jar.")
  498.         (dun-remove-obj-from-inven obj1)
  499.         (setq dun-jar (append dun-jar (list obj1)))
  500.         (dun-mprincl "Done."))
  501.     (if (= obj2 obj-chute)                 ;; Put something in chute
  502.         (progn
  503.           (dun-remove-obj-from-inven obj1)
  504.           (dun-mprincl 
  505. "You hear it slide down the chute and off into the distance.")
  506.           (dun-put-objs-in-treas (list obj1)))
  507.       (if (= obj2 obj-box)              ;; Put key in key box
  508.           (if (= obj1 obj-key)
  509.           (progn
  510.             (dun-mprincl
  511. "As you drop the key, the box begins to shake.  Finally it explodes
  512. with a bang.  The key seems to have vanished!")
  513.             (dun-remove-obj-from-inven obj1)
  514.             (dun-replace dun-room-objects computer-room (append
  515.                             (nth computer-room
  516.                                  dun-room-objects)
  517.                             (list obj1)))
  518.             (dun-remove-obj-from-room dun-current-room obj-box)
  519.             (setq dun-key-level (1+ dun-key-level)))
  520.         (dun-mprincl "You can't put that in the key box!"))
  521.  
  522.         (if (and (= obj1 obj-floppy) (= obj2 obj-pc))
  523.         (progn
  524.           (setq dun-floppy t)
  525.           (dun-remove-obj-from-inven obj1)
  526.           (dun-mprincl "Done."))
  527.  
  528.           (if (= obj2 obj-urinal)                   ;; Put object in urinal
  529.           (progn
  530.             (dun-remove-obj-from-inven obj1)
  531.             (dun-replace dun-room-objects urinal (append 
  532.                           (nth urinal dun-room-objects)
  533.                            (list obj1)))
  534.             (dun-mprincl
  535.              "You hear it plop down in some water below."))
  536.         (if (= obj2 obj-mail)
  537.             (dun-mprincl "The mail chute is locked.")
  538.           (if (member obj1 dun-inventory)
  539.               (dun-mprincl 
  540. "I don't know how to combine those objects.  Perhaps you should
  541. just try dropping it.")
  542.             (dun-mprincl"You can't put that there.")))))))))))
  543.  
  544. (defun dun-type (args)
  545.   (if (not (= dun-current-room computer-room))
  546.       (dun-mprincl "There is nothing here on which you could type.")
  547.     (if (not dun-computer)
  548.     (dun-mprincl 
  549. "You type on the keyboard, but your characters do not even echo.")
  550.       (dun-unix-interface))))
  551.  
  552. ;;; Various movement directions
  553.  
  554. (defun dun-n (args)
  555.   (dun-move north))
  556.  
  557. (defun dun-s (args)
  558.   (dun-move south))
  559.  
  560. (defun dun-e (args)
  561.   (dun-move east))
  562.  
  563. (defun dun-w (args)
  564.   (dun-move west))
  565.  
  566. (defun dun-ne (args)
  567.   (dun-move northeast))
  568.  
  569. (defun dun-se (args)
  570.   (dun-move southeast))
  571.  
  572. (defun dun-nw (args)
  573.   (dun-move northwest))
  574.  
  575. (defun dun-sw (args)
  576.   (dun-move southwest))
  577.  
  578. (defun dun-up (args)
  579.   (dun-move up))
  580.  
  581. (defun dun-down (args)
  582.   (dun-move down))
  583.  
  584. (defun dun-in (args)
  585.   (dun-move in))
  586.  
  587. (defun dun-out (args)
  588.   (dun-move out))
  589.  
  590. (defun dun-go (args)
  591.   (if (or (not (car args)) 
  592.       (eq (dun-doverb dun-ignore dun-verblist (car args) 
  593.               (cdr (cdr args))) -1))
  594.       (dun-mprinc "I don't understand where you want me to go.\n")))
  595.  
  596. ;;; Uses the dungeon-map to figure out where we are going.  If the
  597. ;;; requested direction yields 255, we know something special is
  598. ;;; supposed to happen, or perhaps you can't go that way unless
  599. ;;; certain conditions are met.
  600.  
  601. (defun dun-move (dir)
  602.   (if (and (not (member dun-current-room dun-light-rooms)) 
  603.        (not (member obj-lamp dun-inventory)))
  604.       (progn
  605.     (dun-mprinc 
  606. "You trip over a grue and fall into a pit and break every bone in your
  607. body.")
  608.     (dun-die "a grue"))
  609.     (let (newroom)
  610.       (setq newroom (nth dir (nth dun-current-room dungeon-map)))
  611.       (if (eq newroom -1)
  612.       (dun-mprinc "You can't go that way.\n")
  613.     (if (eq newroom 255)
  614.         (dun-special-move dir)
  615.       (setq room -1)
  616.       (setq dun-lastdir dir)
  617.       (if dun-inbus
  618.           (progn
  619.         (if (or (< newroom 58) (> newroom 83))
  620.             (dun-mprincl "The bus cannot go this way.")
  621.           (dun-mprincl 
  622.            "The bus lurches ahead and comes to a screeching halt.")
  623.           (dun-remove-obj-from-room dun-current-room obj-bus)
  624.           (setq dun-current-room newroom)
  625.           (dun-replace dun-room-objects newroom
  626.                (append (nth newroom dun-room-objects)
  627.                    (list obj-bus)))))
  628.         (setq dun-current-room newroom)))))))
  629.  
  630. ;;; Movement in this direction causes something special to happen if the
  631. ;;; right conditions exist.  It may be that you can't go this way unless
  632. ;;; you have a key, or a passage has been opened.
  633.  
  634. ;;; coding note: Each check of the current room is on the same 'if' level,
  635. ;;; i.e. there aren't else's.  If two rooms next to each other have
  636. ;;; specials, and they are connected by specials, this could cause
  637. ;;; a problem.  Be careful when adding them to consider this, and
  638. ;;; perhaps use else's.
  639.  
  640. (defun dun-special-move (dir)
  641.   (if (= dun-current-room building-front)
  642.       (if (not (member obj-key dun-inventory))
  643.       (dun-mprincl "You don't have a key that can open this door.")
  644.     (setq dun-current-room old-building-hallway))
  645.     (if (= dun-current-room north-end-of-cave-passage)
  646.     (let (combo)
  647.       (dun-mprincl 
  648. "You must type a 3 digit combination code to enter this room.")
  649.       (dun-mprinc "Enter it here: ")
  650.       (setq combo (dun-read-line))
  651.       (if (not dun-batch-mode)
  652.           (dun-mprinc "\n"))
  653.       (if (string= combo dun-combination)
  654.           (setq dun-current-room gamma-computing-center)
  655.         (dun-mprincl "Sorry, that combination is incorrect."))))
  656.  
  657.     (if (= dun-current-room bear-hangout)
  658.     (if (member obj-bear (nth bear-hangout dun-room-objects))
  659.         (progn
  660.           (dun-mprinc 
  661. "The bear is very annoyed that you would be so presumptuous as to try
  662. and walk right by it.  He tells you so by tearing your head off.
  663. ")
  664.           (dun-die "a bear"))
  665.       (dun-mprincl "You can't go that way.")))
  666.  
  667.     (if (= dun-current-room vermont-station)
  668.     (progn
  669.       (dun-mprincl
  670. "As you board the train it immediately leaves the station.  It is a very
  671. bumpy ride.  It is shaking from side to side, and up and down.  You
  672. sit down in one of the chairs in order to be more comfortable.")
  673.       (dun-mprincl
  674. "\nFinally the train comes to a sudden stop, and the doors open, and some
  675. force throws you out.  The train speeds away.\n")
  676.       (setq dun-current-room museum-station)))
  677.  
  678.     (if (= dun-current-room old-building-hallway)
  679.     (if (and (member obj-key dun-inventory)
  680.          (> dun-key-level 0))
  681.         (setq dun-current-room meadow)
  682.       (dun-mprincl "You don't have a key that can open this door.")))
  683.  
  684.     (if (and (= dun-current-room maze-button-room) (= dir northwest))
  685.     (if (member obj-weight (nth maze-button-room dun-room-objects))
  686.         (setq dun-current-room 18)
  687.       (dun-mprincl "You can't go that way.")))
  688.  
  689.     (if (and (= dun-current-room maze-button-room) (= dir up))
  690.     (if (member obj-weight (nth maze-button-room dun-room-objects))
  691.         (dun-mprincl "You can't go that way.")
  692.       (setq dun-current-room weight-room)))
  693.  
  694.     (if (= dun-current-room classroom)
  695.     (dun-mprincl "The door is locked."))
  696.  
  697.     (if (or (= dun-current-room lakefront-north) 
  698.         (= dun-current-room lakefront-south))
  699.     (dun-swim nil))
  700.  
  701.     (if (= dun-current-room reception-area)
  702.     (if (not (= dun-sauna-level 3))
  703.         (setq dun-current-room health-club-front)
  704.       (dun-mprincl
  705. "As you exit the building, you notice some flames coming out of one of the
  706. windows.  Suddenly, the building explodes in a huge ball of fire.  The flames
  707. engulf you, and you burn to death.")
  708.       (dun-die "burning")))
  709.  
  710.     (if (= dun-current-room red-room)
  711.     (if (not (member obj-towel (nth red-room dun-room-objects)))
  712.         (setq dun-current-room long-n-s-hallway)
  713.       (dun-mprincl "You can't go that way.")))
  714.  
  715.     (if (and (> dir down) (> dun-current-room gamma-computing-center) 
  716.          (< dun-current-room museum-lobby))
  717.     (if (not (member obj-bus (nth dun-current-room dun-room-objects)))
  718.         (dun-mprincl "You can't go that way.")
  719.       (if (= dir in)
  720.           (if (member obj-license dun-inventory)
  721.           (progn
  722.             (dun-mprincl 
  723.              "You board the bus and get in the driver's seat.")
  724.             (setq dun-nomail t)
  725.             (setq dun-inbus t))
  726.         (dun-mprincl "You are not licensed for this type of vehicle."))
  727.         (dun-mprincl "You hop off the bus.")
  728.         (setq dun-inbus nil)))
  729.       (if (= dun-current-room fifth-oaktree-intersection)
  730.       (if (not dun-inbus)
  731.           (progn
  732.         (dun-mprincl "You fall down the cliff and land on your head.")
  733.         (dun-die "a cliff"))
  734.         (dun-mprincl
  735. "The bus flies off the cliff, and plunges to the bottom, where it explodes.")
  736.         (dun-die "a bus accident")))
  737.       (if (= dun-current-room main-maple-intersection)
  738.       (progn
  739.         (if (not dun-inbus)
  740.         (dun-mprincl "The gate will not open.")
  741.           (dun-mprincl
  742. "As the bus approaches, the gate opens and you drive through.")
  743.           (dun-remove-obj-from-room main-maple-intersection obj-bus)
  744.           (dun-replace dun-room-objects museum-entrance 
  745.                (append (nth museum-entrance dun-room-objects)
  746.                    (list obj-bus)))
  747.           (setq dun-current-room museum-entrance)))))
  748.     (if (= dun-current-room cave-entrance)
  749.     (progn
  750.       (dun-mprincl
  751. "As you enter the room you hear a rumbling noise.  You look back to see
  752. huge rocks sliding down from the ceiling, and blocking your way out.\n")
  753.       (setq dun-current-room misty-room)))))
  754.  
  755. (defun dun-long (args)
  756.   (setq dun-mode "long"))
  757.  
  758. (defun dun-turn (obj)
  759.   (let (objnum direction)
  760.     (when (setq objnum (dun-objnum-from-args-std obj))
  761.       (if (not (or (member objnum (nth dun-current-room dun-room-objects))
  762.            (member objnum (nth dun-current-room dun-room-silents))))
  763.       (dun-mprincl "I don't see that here.")
  764.     (if (not (= objnum obj-dial))
  765.         (dun-mprincl "You can't turn that.")
  766.       (setq direction (dun-firstword (cdr obj)))
  767.       (if (or (not direction) 
  768.           (not (or (string= direction "clockwise")
  769.                (string= direction "counterclockwise"))))
  770.           (dun-mprincl "You must indicate clockwise or counterclockwise.")
  771.         (if (string= direction "clockwise")
  772.         (setq dun-sauna-level (+ dun-sauna-level 1))
  773.           (setq dun-sauna-level (- dun-sauna-level 1)))
  774.         
  775.         (if (< dun-sauna-level 0)
  776.         (progn
  777.           (dun-mprincl 
  778.            "The dial will not turn further in that direction.")
  779.           (setq dun-sauna-level 0))
  780.           (dun-sauna-heat))))))))
  781.  
  782. (defun dun-sauna-heat ()
  783.   (if (= dun-sauna-level 0)
  784.       (dun-mprincl 
  785.        "The termperature has returned to normal room termperature."))
  786.   (if (= dun-sauna-level 1)
  787.       (dun-mprincl "It is now luke warm in here.  You begin to sweat."))
  788.   (if (= dun-sauna-level 2)
  789.       (dun-mprincl "It is pretty hot in here.  It is still very comfortable."))
  790.   (if (= dun-sauna-level 3)
  791.       (progn
  792.     (dun-mprincl 
  793. "It is now very hot.  There is something very refreshing about this.")
  794.     (if (or (member obj-rms dun-inventory) 
  795.         (member obj-rms (nth dun-current-room dun-room-objects)))
  796.         (progn
  797.           (dun-mprincl 
  798. "You notice the wax on your statuette beginning to melt, until it completely
  799. melts off.  You are left with a beautiful diamond!")
  800.           (if (member obj-rms dun-inventory)
  801.           (progn
  802.             (dun-remove-obj-from-inven obj-rms)
  803.             (setq dun-inventory (append dun-inventory 
  804.                         (list obj-diamond))))
  805.         (dun-remove-obj-from-room dun-current-room obj-rms)
  806.         (dun-replace dun-room-objects dun-current-room
  807.              (append (nth dun-current-room dun-room-objects)
  808.                  (list obj-diamond))))))
  809.     (if (or (member obj-floppy dun-inventory)
  810.         (member obj-floppy (nth dun-current-room dun-room-objects)))
  811.         (progn
  812.           (dun-mprincl
  813. "You notice your floppy disk beginning to melt.  As you grab for it, the 
  814. disk bursts into flames, and disintegrates.")
  815.           (if (member obj-floppy dun-inventory)
  816.           (dun-remove-obj-from-inven obj-floppy)
  817.         (dun-remove-obj-from-room dun-current-room obj-floppy))))))
  818.  
  819.   (if (= dun-sauna-level 4)
  820.       (progn
  821.     (dun-mprincl 
  822. "As the dial clicks into place, you immediately burst into flames.")
  823.     (dun-die "burning"))))
  824.  
  825. (defun dun-press (obj)
  826.   (let (objnum)
  827.     (when (setq objnum (dun-objnum-from-args-std obj))
  828.       (if (not (or (member objnum (nth dun-current-room dun-room-objects))
  829.            (member objnum (nth dun-current-room dun-room-silents))))
  830.       (dun-mprincl "I don't see that here.")
  831.     (if (not (member objnum (list obj-button obj-switch)))
  832.         (progn
  833.           (dun-mprinc "You can't ")
  834.           (dun-mprinc (car line-list))
  835.           (dun-mprincl " that."))
  836.       (if (= objnum obj-button)
  837.           (dun-mprincl
  838. "As you press the button, you notice a passageway open up, but
  839. as you release it, the passageway closes."))
  840.       (if (= objnum obj-switch)
  841.           (if dun-black
  842.           (progn
  843.             (dun-mprincl "The button is now in the off position.")
  844.             (setq dun-black nil))
  845.         (dun-mprincl "The button is now in the on position.")
  846.         (setq dun-black t))))))))
  847.  
  848. (defun dun-swim (args)
  849.   (if (not (member dun-current-room (list lakefront-north lakefront-south)))
  850.       (dun-mprincl "I see no water!")
  851.     (if (not (member obj-life dun-inventory))
  852.     (progn
  853.       (dun-mprincl 
  854. "You dive in the water, and at first notice it is quite cold.  You then
  855. start to get used to it as you realize that you never really learned how
  856. to swim.")
  857.       (dun-die "drowning"))
  858.       (if (= dun-current-room lakefront-north)
  859.       (setq dun-current-room lakefront-south)
  860.     (setq dun-current-room lakefront-north)))))
  861.  
  862.  
  863. (defun dun-score (args)
  864.   (if (not dun-endgame)
  865.       (let (total)
  866.     (setq total (dun-reg-score))
  867.     (dun-mprinc "You have scored ")
  868.     (dun-mprinc total)
  869.     (dun-mprincl " out of a possible 90 points.") total)
  870.     (dun-mprinc "You have scored ")
  871.     (dun-mprinc (dun-endgame-score))
  872.     (dun-mprincl " endgame points out of a possible 110.")
  873.     (if (= (dun-endgame-score) 110)
  874.     (dun-mprincl 
  875. "\n\nCongratulations.  You have won.  The wizard password is 'moby'"))))
  876.  
  877. (defun dun-help (args)
  878.   (dun-mprincl
  879. "Welcome to dunnet (2.0), by Ron Schnell (ronnie@media.mit.edu).
  880. Here is some useful information (read carefully because there are one
  881. or more clues in here):
  882. - If you have a key that can open a door, you do not need to explicitly
  883.   open it.  You may just use 'in' or walk in the direction of the door.
  884.  
  885. - If you have a lamp, it is always lit.
  886.  
  887. - You will not get any points until you manage to get treasures to a certain
  888.   place.  Simply finding the treasures is not good enough.  There is more
  889.   than one way to get a treasure to the special place.  It is also
  890.   important that the objects get to the special place *unharmed* and
  891.   *untarnished*.  You can tell if you have successfully transported the
  892.   object by looking at your score, as it changes immediately.  Note that
  893.   an object can become harmed even after you have received points for it.
  894.   If this happens, your score will decrease, and in many cases you can never
  895.   get credit for it again.
  896.  
  897. - You can save your game with the 'save' command, and use restore it
  898.   with the 'restore' command.
  899.  
  900. - There are no limits on lengths of object names.
  901.  
  902. - Directions are: north,south,east,west,northeast,southeast,northwest,
  903.                   southwest,up,down,in,out.
  904.  
  905. - These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.
  906.  
  907. - If you go down a hole in the floor without an aid such as a ladder,
  908.   you probably won't be able to get back up the way you came, if at all.
  909.  
  910. - To run this game in batch mode (no emacs window), use:
  911.      emacs -batch -l dunnet
  912.  
  913. If you have questions or comments, please contact ronnie@media.mit.edu."))
  914.  
  915. (defun dun-flush (args)
  916.   (if (not (= dun-current-room bathroom))
  917.       (dun-mprincl "I see nothing to flush.")
  918.     (dun-mprincl "Whoooosh!!")
  919.     (dun-put-objs-in-treas (nth urinal dun-room-objects))
  920.     (dun-replace dun-room-objects urinal nil)))
  921.  
  922. (defun dun-piss (args)
  923.   (if (not (= dun-current-room bathroom))
  924.       (dun-mprincl "You can't do that here, don't even bother trying.")
  925.     (if (not dun-gottago)
  926.     (dun-mprincl "I'm afraid you don't have to go now.")
  927.       (dun-mprincl "That was refreshing.")
  928.       (setq dun-gottago nil)
  929.       (dun-replace dun-room-objects urinal (append 
  930.                         (nth urinal dun-room-objects)
  931.                         (list obj-URINE))))))
  932.  
  933.  
  934. (defun dun-sleep (args)
  935.   (if (not (= dun-current-room bedroom))
  936.       (dun-mprincl
  937. "You try to go to sleep while standing up here, but can't seem to do it.")
  938.     (setq dun-gottago t)
  939.     (dun-mprincl
  940. "As soon as you start to doze off you begin dreaming.  You see images of
  941. workers digging caves, slaving in the humid heat.  Then you see yourself
  942. as one of these workers.  While no one is looking, you leave the group
  943. and walk into a room.  The room is bare except for a horseshoe
  944. shaped piece of stone in the center.  You see yourself digging a hole in
  945. the ground, then putting some kind of treasure in it, and filling the hole
  946. with dirt again.  After this, you immediately wake up.")))
  947.  
  948. (defun dun-break (obj)
  949.   (let (objnum)
  950.     (if (not (member obj-axe dun-inventory))
  951.     (dun-mprincl "You have nothing you can use to break things.")
  952.       (when (setq objnum (dun-objnum-from-args-std obj))
  953.     (if (member objnum dun-inventory)
  954.         (progn
  955.           (dun-mprincl
  956. "You take the object in your hands and swing the axe.  Unfortunately, you miss
  957. the object and slice off your hand.  You bleed to death.")
  958.           (dun-die "an axe"))
  959.       (if (not (or (member objnum (nth dun-current-room dun-room-objects))
  960.                (member objnum 
  961.                    (nth dun-current-room dun-room-silents))))
  962.           (dun-mprincl "I don't see that here.")
  963.         (if (= objnum obj-cable)
  964.         (progn
  965.           (dun-mprincl 
  966. "As you break the ethernet cable, everything starts to blur.  You collapse
  967. for a moment, then straighten yourself up.
  968. ")
  969.           (dun-replace dun-room-objects gamma-computing-center
  970.                (append 
  971.                 (nth gamma-computing-center dun-room-objects)
  972.                 dun-inventory))
  973.           (if (member obj-key dun-inventory)
  974.               (progn
  975.             (setq dun-inventory (list obj-key))
  976.             (dun-remove-obj-from-room 
  977.              gamma-computing-center obj-key))
  978.             (setq dun-inventory nil))
  979.           (setq dun-current-room computer-room)
  980.           (setq dun-ethernet nil)
  981.           (dun-mprincl "Connection closed.")
  982.           (dun-unix-interface))
  983.           (if (< objnum 0)
  984.           (progn
  985.             (dun-mprincl "Your axe shatters into a million pieces.")
  986.             (dun-remove-obj-from-inven obj-axe))
  987.         (dun-mprincl "Your axe breaks it into a million pieces.")
  988.         (dun-remove-obj-from-room dun-current-room objnum)))))))))
  989.  
  990. (defun dun-drive (args)
  991.   (if (not dun-inbus)
  992.       (dun-mprincl "You cannot drive when you aren't in a vehicle.")
  993.     (dun-mprincl "To drive while you are in the bus, just give a direction.")))
  994.  
  995. (defun dun-superb (args)
  996.   (setq dun-mode 'dun-superb))
  997.  
  998. (defun dun-reg-score ()
  999.   (let (total)
  1000.     (setq total 0)
  1001.     (dolist (x (nth treasure-room dun-room-objects))
  1002.       (setq total (+ total (nth x dun-object-pts))))
  1003.     (if (member obj-URINE (nth treasure-room dun-room-objects))
  1004.     (setq total 0)) total))
  1005.  
  1006. (defun dun-endgame-score ()
  1007.   (let (total)
  1008.     (setq total 0)
  1009.     (dolist (x (nth endgame-treasure-room dun-room-objects))
  1010.       (setq total (+ total (nth x dun-object-pts)))) total))
  1011.  
  1012. (defun dun-answer (args)
  1013.   (if (not dun-correct-answer)
  1014.       (dun-mprincl "I don't believe anyone asked you anything.")
  1015.     (setq args (car args))
  1016.     (if (not args)
  1017.     (dun-mprincl "You must give the answer on the same line.")
  1018.       (if (dun-members args dun-correct-answer)
  1019.       (progn
  1020.         (dun-mprincl "Correct.")
  1021.         (if (= dun-lastdir 0)
  1022.         (setq dun-current-room (1+ dun-current-room))
  1023.           (setq dun-current-room (- dun-current-room 1)))
  1024.         (setq dun-correct-answer nil))
  1025.     (dun-mprincl "That answer is incorrect.")))))
  1026.  
  1027. (defun dun-endgame-question ()
  1028. (if (not dun-endgame-questions)
  1029.     (progn
  1030.       (dun-mprincl "Your question is:")
  1031.       (dun-mprincl "No more questions, just do 'answer foo'.")
  1032.       (setq dun-correct-answer '("foo")))
  1033.   (let (which i newques)
  1034.     (setq i 0)
  1035.     (setq newques nil)
  1036.     (setq which (% (abs (random)) (length dun-endgame-questions)))
  1037.     (dun-mprincl "Your question is:")
  1038.     (dun-mprincl (setq dun-endgame-question (car 
  1039.                          (nth which 
  1040.                           dun-endgame-questions))))
  1041.     (setq dun-correct-answer (cdr (nth which dun-endgame-questions)))
  1042.     (while (< i which)
  1043.       (setq newques (append newques (list (nth i dun-endgame-questions))))
  1044.       (setq i (1+ i)))
  1045.     (setq i (1+ which))
  1046.     (while (< i (length dun-endgame-questions))
  1047.       (setq newques (append newques (list (nth i dun-endgame-questions))))
  1048.       (setq i (1+ i)))
  1049.     (setq dun-endgame-questions newques))))
  1050.  
  1051. (defun dun-power (args)
  1052.   (if (not (= dun-current-room pc-area))
  1053.       (dun-mprincl "That operation is not applicable here.")
  1054.     (if (not dun-floppy)
  1055.     (dun-dos-no-disk)
  1056.       (dun-dos-interface))))
  1057.  
  1058. (defun dun-feed (args)
  1059.   (let (objnum)
  1060.     (when (setq objnum (dun-objnum-from-args-std args))
  1061.       (if (and (= objnum obj-bear) 
  1062.            (member obj-bear (nth dun-current-room dun-room-objects)))
  1063.       (progn
  1064.         (if (not (member obj-food dun-inventory))
  1065.         (dun-mprincl "You have nothing with which to feed it.")
  1066.           (dun-drop '("food"))))
  1067.     (if (not (or (member objnum (nth dun-current-room dun-room-objects))
  1068.              (member objnum dun-inventory)
  1069.              (member objnum (nth dun-current-room dun-room-silents))))
  1070.         (dun-mprincl "I don't see that here.")
  1071.       (dun-mprincl "You cannot feed that."))))))
  1072.  
  1073.  
  1074. ;;;;
  1075. ;;;;  This section defines various utility functions used
  1076. ;;;;  by dunnet.
  1077. ;;;;
  1078.  
  1079.  
  1080. ;;; Function which takes a verb and a list of other words.  Calls proper
  1081. ;;; function associated with the verb, and passes along the other words.
  1082.  
  1083. (defun dun-doverb (dun-ignore dun-verblist verb rest)
  1084.   (if (not verb)
  1085.       nil
  1086.     (if (member (intern verb) dun-ignore)
  1087.     (if (not (car rest)) -1
  1088.       (dun-doverb dun-ignore dun-verblist (car rest) (cdr rest)))
  1089.       (if (not (cdr (assq (intern verb) dun-verblist))) -1
  1090.     (setq dun-numcmds (1+ dun-numcmds))
  1091.     (eval (list (cdr (assq (intern verb) dun-verblist)) (quote rest)))))))
  1092.  
  1093.  
  1094. ;;; Function to take a string and change it into a list of lowercase words.
  1095.  
  1096. (defun dun-listify-string (strin)
  1097.   (let (pos ret-list end-pos)
  1098.     (setq pos 0)
  1099.     (setq ret-list nil)
  1100.     (while (setq end-pos (string-match "[ ,:;]" (substring strin pos)))
  1101.       (setq end-pos (+ end-pos pos))
  1102.       (if (not (= end-pos pos))
  1103.       (setq ret-list (append ret-list (list 
  1104.                        (downcase
  1105.                         (substring strin pos end-pos))))))
  1106.       (setq pos (+ end-pos 1))) ret-list))
  1107.  
  1108. (defun dun-listify-string2 (strin)
  1109.   (let (pos ret-list end-pos)
  1110.     (setq pos 0)
  1111.     (setq ret-list nil)
  1112.     (while (setq end-pos (string-match " " (substring strin pos)))
  1113.       (setq end-pos (+ end-pos pos))
  1114.       (if (not (= end-pos pos))
  1115.       (setq ret-list (append ret-list (list 
  1116.                        (downcase
  1117.                         (substring strin pos end-pos))))))
  1118.       (setq pos (+ end-pos 1))) ret-list))
  1119.  
  1120. (defun dun-replace (list n number)
  1121.   (rplaca (nthcdr n list) number))
  1122.  
  1123.  
  1124. ;;; Get the first non-ignored word from a list.
  1125.  
  1126. (defun dun-firstword (list)
  1127.   (if (not (car list))
  1128.       nil
  1129.     (while (and list (member (intern (car list)) dun-ignore))
  1130.       (setq list (cdr list)))
  1131.     (car list)))
  1132.  
  1133. (defun dun-firstwordl (list)
  1134.   (if (not (car list))
  1135.       nil
  1136.     (while (and list (member (intern (car list)) dun-ignore))
  1137.       (setq list (cdr list)))
  1138.     list))
  1139.  
  1140. ;;; parse a line passed in as a string  Call the proper verb with the
  1141. ;;; rest of the line passed in as a list.
  1142.  
  1143. (defun dun-vparse (dun-ignore dun-verblist line)
  1144.   (dun-mprinc "\n")
  1145.   (setq line-list (dun-listify-string (concat line " ")))
  1146.   (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
  1147.  
  1148. (defun dun-parse2 (dun-ignore dun-verblist line)
  1149.   (dun-mprinc "\n")
  1150.   (setq line-list (dun-listify-string2 (concat line " ")))
  1151.   (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
  1152.  
  1153. ;;; Read a line, in window mode
  1154.  
  1155. (defun dun-read-line ()
  1156.   (let (line)
  1157.     (setq line (read-string ""))
  1158.     (dun-mprinc line) line))
  1159.  
  1160. ;;; Insert something into the window buffer
  1161.  
  1162. (defun dun-minsert (string)
  1163.   (if (stringp string)
  1164.       (insert string)
  1165.     (insert (prin1-to-string string))))
  1166.  
  1167. ;;; Print something out, in window mode
  1168.  
  1169. (defun dun-mprinc (string)
  1170.   (if (stringp string)
  1171.       (insert string)
  1172.     (insert (prin1-to-string string))))
  1173.  
  1174. ;;; In window mode, keep screen from jumping by keeping last line at
  1175. ;;; the bottom of the screen.
  1176.  
  1177. (defun dun-fix-screen ()
  1178.   (interactive)
  1179.   (forward-line (- 0 (- (window-height) 2 )))
  1180.   (set-window-start (selected-window) (point))
  1181.   (end-of-buffer))
  1182.  
  1183. ;;; Insert something into the buffer, followed by newline.
  1184.  
  1185. (defun dun-minsertl (string)
  1186.   (dun-minsert string)
  1187.   (dun-minsert "\n"))
  1188.  
  1189. ;;; Print something, followed by a newline.
  1190.  
  1191. (defun dun-mprincl (string)
  1192.   (dun-mprinc string)
  1193.   (dun-mprinc "\n"))
  1194.  
  1195. ;;; Function which will get an object number given the list of
  1196. ;;; words in the command, except for the verb.
  1197.  
  1198. (defun dun-objnum-from-args (obj)
  1199.   (let (objnum)
  1200.     (setq obj (dun-firstword obj))
  1201.     (if (not obj)
  1202.     obj-special
  1203.       (setq objnum (cdr (assq (intern obj) dun-objnames))))))
  1204.  
  1205. (defun dun-objnum-from-args-std (obj)
  1206.   (let (result)
  1207.   (if (eq (setq result (dun-objnum-from-args obj)) obj-special)
  1208.       (dun-mprincl "You must supply an object."))
  1209.   (if (eq result nil)
  1210.       (dun-mprincl "I don't know what that is."))
  1211.   (if (eq result obj-special)
  1212.       nil
  1213.     result)))
  1214.  
  1215. ;;; Take a short room description, and change spaces and slashes to dashes.
  1216.  
  1217. (defun dun-space-to-hyphen (string)
  1218.   (let (space)
  1219.     (if (setq space (string-match "[ /]" string))
  1220.     (progn
  1221.       (setq string (concat (substring string 0 space) "-"
  1222.                    (substring string (1+ space))))
  1223.       (dun-space-to-hyphen string))
  1224.       string)))
  1225.  
  1226. ;;; Given a unix style pathname, build a list of path components (recursive)
  1227.  
  1228. (defun dun-get-path (dirstring startlist)
  1229.   (let (slash pos)
  1230.     (if (= (length dirstring) 0)
  1231.     startlist
  1232.       (if (string= (substring dirstring 0 1) "/")
  1233.       (dun-get-path (substring dirstring 1) (append startlist (list "/")))
  1234.     (if (not (setq slash (string-match "/" dirstring)))
  1235.         (append startlist (list dirstring))
  1236.       (dun-get-path (substring dirstring (1+ slash))
  1237.             (append startlist
  1238.                 (list (substring dirstring 0 slash)))))))))
  1239.  
  1240.  
  1241. ;;; Is a string a member of a string list?
  1242.  
  1243. (defun dun-members (string string-list)
  1244.   (let (found)
  1245.     (setq found nil)
  1246.     (dolist (x string-list)
  1247.       (if (string= x string)
  1248.       (setq found t))) found))
  1249.  
  1250. ;;; Function to put objects in the treasure room.  Also prints current
  1251. ;;; score to let user know he has scored.
  1252.  
  1253. (defun dun-put-objs-in-treas (objlist)
  1254.   (let (oscore newscore)
  1255.     (setq oscore (dun-reg-score))
  1256.     (dun-replace dun-room-objects 0 (append (nth 0 dun-room-objects) objlist))
  1257.     (setq newscore (dun-reg-score))
  1258.     (if (not (= oscore newscore))
  1259.     (dun-score nil))))
  1260.  
  1261. ;;; Load an encrypted file, and eval it.
  1262.  
  1263. (defun dun-load-d (filename)
  1264.   (let (old-buffer result)
  1265.     (setq result t)
  1266.     (setq old-buffer (current-buffer))
  1267.     (switch-to-buffer (get-buffer-create "*loadc*"))
  1268.     (erase-buffer)
  1269.     (condition-case nil
  1270.     (insert-file-contents filename)
  1271.       (error (setq result nil)))
  1272.     (unless (not result)
  1273.       (condition-case nil
  1274.       (dun-rot13)
  1275.     (error (yank)))
  1276.       (eval-current-buffer)
  1277.       (kill-buffer (current-buffer))
  1278.       (switch-to-buffer old-buffer))
  1279.     result))
  1280.  
  1281. ;;; Functions to remove an object either from a room, or from inventory.
  1282.  
  1283. (defun dun-remove-obj-from-room (room objnum)
  1284.   (let (newroom)
  1285.     (setq newroom nil)
  1286.     (dolist (x (nth room dun-room-objects))
  1287.       (if (not (= x objnum))
  1288.       (setq newroom (append newroom (list x)))))
  1289.     (rplaca (nthcdr room dun-room-objects) newroom)))
  1290.  
  1291. (defun dun-remove-obj-from-inven (objnum)
  1292.   (let (new-inven)
  1293.     (setq new-inven nil)
  1294.     (dolist (x dun-inventory)
  1295.       (if (not (= x objnum))
  1296.       (setq new-inven (append new-inven (list x)))))
  1297.     (setq dun-inventory new-inven)))
  1298.  
  1299.  
  1300. (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
  1301.   (setq dun-translate-table (make-vector 256 0))
  1302.   (while (< i 256)
  1303.     (aset dun-translate-table i i)
  1304.     (setq i (1+ i)))
  1305.   (setq lower (concat lower lower))
  1306.   (setq upper (upcase lower))
  1307.   (setq i 0)
  1308.   (while (< i 26)
  1309.     (aset dun-translate-table (+ ?a i) (aref lower (+ i 13)))
  1310.     (aset dun-translate-table (+ ?A i) (aref upper (+ i 13)))
  1311.       (setq i (1+ i))))
  1312.   
  1313. (defun dun-rot13 ()
  1314.   (let (str len (i 0))
  1315.     (setq str (buffer-substring (point-min) (point-max)))
  1316.     (setq len (length str))
  1317.     (while (< i len)
  1318.       (aset str i (aref dun-translate-table (aref str i)))
  1319.       (setq i (1+ i)))
  1320.     (erase-buffer)
  1321.     (insert str)))
  1322.  
  1323. ;;;;
  1324. ;;;; This section defines the globals that are used in dunnet.
  1325. ;;;;
  1326. ;;;; IMPORTANT
  1327. ;;;; All globals which can change must be saved from 'save-game.  Add
  1328. ;;;; all new globals to bottom of file.
  1329.  
  1330. (setq dun-visited '(27))
  1331. (setq dun-current-room 1)
  1332. (setq dun-exitf nil)
  1333. (setq dun-badcd nil)
  1334. (defvar dungeon-mode-map nil)
  1335. (setq dungeon-mode-map (make-sparse-keymap))
  1336. (define-key dungeon-mode-map "\r" 'dun-parse)
  1337. (defvar dungeon-batch-map (make-keymap))
  1338. (if (string= (substring emacs-version 0 2) "18")
  1339.     (let (n)
  1340.       (setq n 32)
  1341.       (while (< 0 (setq n (- n 1)))
  1342.     (aset dungeon-batch-map n 'dungeon-nil)))
  1343.   (let (n)
  1344.     (setq n 32)
  1345.     (while (< 0 (setq n (- n 1)))
  1346.       (aset (car (cdr dungeon-batch-map)) n 'dungeon-nil))))
  1347. (define-key dungeon-batch-map "\r" 'exit-minibuffer)
  1348. (define-key dungeon-batch-map "\n" 'exit-minibuffer)
  1349. (setq dun-computer nil)
  1350. (setq dun-floppy nil)
  1351. (setq dun-key-level 0)
  1352. (setq dun-hole nil)
  1353. (setq dun-correct-answer nil)
  1354. (setq dun-lastdir 0)
  1355. (setq dun-numsaves 0)
  1356. (setq dun-jar nil)
  1357. (setq dun-dead nil)
  1358. (setq room 0)
  1359. (setq dun-numcmds 0)
  1360. (setq dun-wizard nil)
  1361. (setq dun-endgame-question nil)
  1362. (setq dun-logged-in nil)
  1363. (setq dungeon-mode 'dungeon)
  1364. (setq dun-unix-verbs '((ls . dun-ls) (ftp . dun-ftp) (echo . dun-echo) 
  1365.                (exit . dun-uexit) (cd . dun-cd) (pwd . dun-pwd)
  1366.                (rlogin . dun-rlogin) (uncompress . dun-uncompress)
  1367.                (cat . dun-cat) (zippy . dun-zippy)))
  1368.  
  1369. (setq dun-dos-verbs '((dir . dun-dos-dir) (type . dun-dos-type)
  1370.               (exit . dun-dos-exit) (command . dun-dos-spawn)
  1371.               (b: . dun-dos-invd) (c: . dun-dos-invd)
  1372.               (a: . dun-dos-nil)))
  1373.  
  1374.  
  1375. (setq dun-batch-mode nil)
  1376.  
  1377. (setq dun-cdpath "/usr/toukmond")
  1378. (setq dun-cdroom -10)
  1379. (setq dun-uncompressed nil)
  1380. (setq dun-ethernet t)
  1381. (setq dun-restricted 
  1382.       '(dun-room-objects dungeon-map dun-rooms 
  1383.              dun-room-silents dun-combination))
  1384. (setq dun-ftptype 'ascii)
  1385. (setq dun-endgame nil)
  1386. (setq dun-gottago t)
  1387. (setq dun-black nil)
  1388.  
  1389. (setq dun-rooms '(
  1390.           (
  1391. "You are in the treasure room.  A door leads out to the north."
  1392.                "Treasure room"
  1393.            )
  1394.           (
  1395. "You are at a dead end of a dirt road.  The road goes to the east.
  1396. In the distance you can see that it will eventually fork off.  The
  1397. trees here are very tall royal palms, and they are spaced equidistant
  1398. from each other."
  1399.            "Dead end"
  1400.            )
  1401.           (
  1402. "You are on the continuation of a dirt road.  There are more trees on
  1403. both sides of you.  The road continues to the east and west."
  1404.                "E/W Dirt road"
  1405.            )
  1406.           (
  1407. "You are at a fork of two passages, one to the northeast, and one to the
  1408. southeast.  The ground here seems very soft. You can also go back west."
  1409.                "Fork"
  1410.            )
  1411.           (
  1412. "You are on a northeast/southwest road."
  1413.                "NE/SW road"
  1414.            )
  1415.           (
  1416. "You are at the end of the road.  There is a building in front of you
  1417. to the northeast, and the road leads back to the southwest."
  1418.                "Building front"
  1419.            )
  1420.           (
  1421. "You are on a southeast/northwest road."
  1422.                "SE/NW road"
  1423.            )
  1424.           (
  1425. "You are standing at the end of a road.  A passage leads back to the
  1426. northwest."
  1427.                "Bear hangout"
  1428.            )
  1429.           (
  1430. "You are in the hallway of an old building.  There are rooms to the east
  1431. and west, and doors leading out to the north and south."
  1432.                "Old Building hallway"
  1433.            )
  1434.           (
  1435. "You are in a mailroom.  There are many bins where the mail is usually
  1436. kept.  The exit is to the west."
  1437.                "Mailroom"
  1438.            )
  1439.           (
  1440. "You are in a computer room.  It seems like most of the equipment has
  1441. been removed.  There is a VAX 11/780 in front of you, however, with
  1442. one of the cabinets wide open.  A sign on the front of the machine
  1443. says: This VAX is named 'pokey'.  To type on the console, use the
  1444. 'type' command.  The exit is to the east."
  1445.                "Computer room"
  1446.            )
  1447.           (
  1448. "You are in a meadow in the back of an old building.  A small path leads
  1449. to the west, and a door leads to the south."
  1450.                "Meadow"
  1451.            )
  1452.           (
  1453. "You are in a round, stone room with a door to the east.  There
  1454. is a sign on the wall that reads: 'receiving room'."
  1455.                "Receiving room"
  1456.            )
  1457.           (
  1458. "You are at the south end of a hallway that leads to the north.  There
  1459. are rooms to the east and west."
  1460.                "Northbound Hallway"
  1461.            )
  1462.           (
  1463. "You are in a sauna.  There is nothing in the room except for a dial
  1464. on the wall.  A door leads out to west."
  1465.                "Sauna"
  1466.                )
  1467.           (
  1468. "You are at the end of a north/south hallway.  You can go back to the south,
  1469. or off to a room to the east."
  1470.                "End of N/S Hallway"
  1471.            )
  1472.           (
  1473. "You are in an old weight room.  All of the equipment is either destroyed
  1474. or completely broken.  There is a door out to the west, and there is a ladder
  1475. leading down a hole in the floor."
  1476.                "Weight room"                 ;16
  1477.            )
  1478.           (
  1479. "You are in a maze of twisty little passages, all alike.
  1480. There is a button on the ground here."
  1481.                "Maze button room"
  1482.            )
  1483.           (
  1484. "You are in a maze of little twisty passages, all alike."
  1485.                "Maze"
  1486.            )
  1487.           (
  1488. "You are in a maze of thirsty little passages, all alike."
  1489.                "Maze"    ;19
  1490.            )
  1491.           (
  1492. "You are in a maze of twenty little passages, all alike."
  1493.                "Maze"
  1494.            )
  1495.           (
  1496. "You are in a daze of twisty little passages, all alike."
  1497.                "Maze"   ;21
  1498.            )
  1499.           (
  1500. "You are in a maze of twisty little cabbages, all alike."
  1501.                "Maze"   ;22
  1502.            )
  1503.           (
  1504. "You are in a reception area for a health and fitness center.  The place
  1505. appears to have been recently ransacked, and nothing is left.  There is
  1506. a door out to the south, and a crawlspace to the southeast."
  1507.                "Reception area"
  1508.            )
  1509.           (
  1510. "You are outside a large building to the north which used to be a health
  1511. and fitness center.  A road leads to the south."
  1512.                "Health Club front"
  1513.            )
  1514.           (
  1515. "You are at the north side of a lake.  On the other side you can see
  1516. a road which leads to a cave.  The water appears very deep."
  1517.                "Lakefront North"
  1518.            )
  1519.           (
  1520. "You are at the south side of a lake.  A road goes to the south."
  1521.                "Lakefront South"
  1522.            )
  1523.           (
  1524. "You are in a well-hidden area off to the side of a road.  Back to the
  1525. northeast through the brush you can see the bear hangout."
  1526.                "Hidden area"
  1527.            )
  1528.           (
  1529. "The entrance to a cave is to the south.  To the north, a road leads
  1530. towards a deep lake.  On the ground nearby there is a chute, with a sign
  1531. that says 'put treasures here for points'."
  1532.                "Cave Entrance"                      ;28
  1533.            )
  1534.           (
  1535. "You are in a misty, humid room carved into a mountain.
  1536. To the north is the remains of a rockslide.  To the east, a small
  1537. passage leads away into the darkness."              ;29
  1538.                "Misty Room"
  1539.            )
  1540.           (
  1541. "You are in an east/west passageway.  The walls here are made of
  1542. multicolored rock and are quite beautiful."
  1543.                "Cave E/W passage"                   ;30
  1544.            )
  1545.           (
  1546. "You are at the junction of two passages. One goes north/south, and
  1547. the other goes west."
  1548.                "N/S/W Junction"                     ;31
  1549.            )
  1550.           (
  1551. "You are at the north end of a north/south passageway.  There are stairs
  1552. leading down from here.  There is also a door leading west."
  1553.                "North end of cave passage"         ;32
  1554.            )
  1555.           (
  1556. "You are at the south end of a north/south passageway.  There is a hole
  1557. in the floor here, into which you could probably fit."
  1558.                "South end of cave passage"         ;33
  1559.            )
  1560.           (
  1561. "You are in what appears to be a worker's bedroom.  There is a queen-
  1562. sized bed in the middle of the room, and a painting hanging on the
  1563. wall.  A door leads to another room to the south, and stairways
  1564. lead up and down."
  1565.                "Bedroom"                          ;34
  1566.            )
  1567.           (
  1568. "You are in a bathroom built for workers in the cave.  There is a
  1569. urinal hanging on the wall, and some exposed pipes on the opposite
  1570. wall where a sink used to be.  To the north is a bedroom."
  1571.                "Bathroom"        ;35
  1572.            )
  1573.           (
  1574. "This is a marker for the urinal.  User will not see this, but it
  1575. is a room that can contain objects."
  1576.                "Urinal"          ;36
  1577.            )
  1578.           (
  1579. "You are at the northeast end of a northeast/southwest passageway.
  1580. Stairs lead up out of sight."
  1581.                "Ne end of ne/sw cave passage"       ;37
  1582.            )
  1583.           (
  1584. "You are at the junction of northeast/southwest and east/west passages."
  1585.                "Ne/sw-e/w junction"                      ;38
  1586.            )
  1587.           (
  1588. "You are at the southwest end of a northeast/southwest passageway."
  1589.                "Sw end of ne/sw cave passage"        ;39
  1590.            )
  1591.           (
  1592. "You are at the east end of an e/w passage.  There are stairs leading up
  1593. to a room above."
  1594.                "East end of e/w cave passage"    ;40
  1595.            )
  1596.           (
  1597. "You are at the west end of an e/w passage.  There is a hole on the ground
  1598. which leads down out of sight."
  1599.                "West end of e/w cave passage"    ;41
  1600.            )
  1601.           (
  1602. "You are in a room which is bare, except for a horseshoe shaped boulder
  1603. in the center.  Stairs lead down from here."     ;42
  1604.                "Horseshoe boulder room"
  1605.            )
  1606.           (
  1607. "You are in a room which is completely empty.  Doors lead out to the north
  1608. and east."
  1609.                "Empty room"                      ;43
  1610.            )
  1611.           (
  1612. "You are in an empty room.  Interestingly enough, the stones in this
  1613. room are painted blue.  Doors lead out to the east and south."  ;44
  1614.                "Blue room"
  1615.            )
  1616.           (
  1617. "You are in an empty room.  Interestingly enough, the stones in this
  1618. room are painted yellow.  Doors lead out to the south and west."    ;45
  1619.                "Yellow room"
  1620.            )
  1621.           (
  1622. "You are in an empty room.  Interestingly enough, the stones in this room
  1623. are painted red.  Doors lead out to the west and north."
  1624.                "Red room"                                 ;46
  1625.            )
  1626.           (
  1627. "You are in the middle of a long north/south hallway."     ;47
  1628.                "Long n/s hallway"
  1629.            )
  1630.           (
  1631. "You are 3/4 of the way towards the north end of a long north/south hallway."
  1632.                "3/4 north"                                ;48
  1633.            )
  1634.           (
  1635. "You are at the north end of a long north/south hallway.  There are stairs
  1636. leading upwards."
  1637.                "North end of long hallway"                 ;49
  1638.            )
  1639.           (
  1640. "You are 3/4 of the way towards the south end of a long north/south hallway."
  1641.                "3/4 south"                                 ;50
  1642.            )
  1643.           (
  1644. "You are at the south end of a long north/south hallway.  There is a hole
  1645. to the south."
  1646.                "South end of long hallway"                 ;51
  1647.            )
  1648.           (
  1649. "You are at a landing in a stairwell which continues up and down."
  1650.                "Stair landing"                             ;52
  1651.            )
  1652.           (
  1653. "You are at the continuation of an up/down staircase."
  1654.                "Up/down staircase"                         ;53
  1655.            )
  1656.           (
  1657. "You are at the top of a staircase leading down.  A crawlway leads off
  1658. to the northeast."
  1659.                "Top of staircase."                        ;54
  1660.            )
  1661.           (
  1662. "You are in a crawlway that leads northeast or southwest."
  1663.                "Ne crawlway"                              ;55
  1664.            )
  1665.           (
  1666. "You are in a small crawlspace.  There is a hole in the ground here, and
  1667. a small passage back to the southwest."
  1668.                "Small crawlspace"                         ;56
  1669.            )
  1670.           (
  1671. "You are in the Gamma Computing Center.  An IBM 3090/600s is whirring
  1672. away in here.  There is an ethernet cable coming out of one of the units,
  1673. and going through the ceiling.  There is no console here on which you
  1674. could type."
  1675.                "Gamma computing center"                   ;57
  1676.            )
  1677.           (
  1678. "You are near the remains of a post office.  There is a mail drop on the
  1679. face of the building, but you cannot see where it leads.  A path leads
  1680. back to the east, and a road leads to the north."
  1681.                "Post office"                             ;58
  1682.            )
  1683.           (
  1684. "You are at the intersection of Main Street and Maple Ave.  Main street
  1685. runs north and south, and Maple Ave runs east off into the distance.
  1686. If you look north and east you can see many intersections, but all of
  1687. the buildings that used to stand here are gone.  Nothing remains except
  1688. street signs.
  1689. There is a road to the northwest leading to a gate that guards a building."
  1690.                "Main-Maple intersection"                       ;59
  1691.            )
  1692.           (
  1693. "You are at the intersection of Main Street and the west end of Oaktree Ave."
  1694.                "Main-Oaktree intersection"   ;60
  1695.            )
  1696.           (
  1697. "You are at the intersection of Main Street and the west end of Vermont Ave."
  1698.                "Main-Vermont intersection"  ;61
  1699.            )
  1700.           (
  1701. "You are at the north end of Main Street at the west end of Sycamore Ave." ;62
  1702.                "Main-Sycamore intersection"
  1703.            )
  1704.           (
  1705. "You are at the south end of First Street at Maple Ave." ;63
  1706.                "First-Maple intersection"
  1707.            )
  1708.           (
  1709. "You are at the intersection of First Street and Oaktree Ave."  ;64
  1710.                "First-Oaktree intersection"
  1711.            )
  1712.           (
  1713. "You are at the intersection of First Street and Vermont Ave."  ;65
  1714.                "First-Vermont intersection"
  1715.            )
  1716.           (
  1717. "You are at the north end of First Street at Sycamore Ave."  ;66
  1718.                "First-Sycamore intersection"
  1719.            )
  1720.           (
  1721. "You are at the south end of Second Street at Maple Ave."  ;67
  1722.                "Second-Maple intersection"
  1723.            )
  1724.           (
  1725. "You are at the intersection of Second Street and Oaktree Ave."  ;68
  1726.                "Second-Oaktree intersection"
  1727.            )
  1728.           (
  1729. "You are at the intersection of Second Street and Vermont Ave."  ;69
  1730.                "Second-Vermont intersection"
  1731.            )
  1732.           (
  1733. "You are at the north end of Second Street at Sycamore Ave."  ;70
  1734.                "Second-Sycamore intersection"
  1735.            )
  1736.           (
  1737. "You are at the south end of Third Street at Maple Ave."  ;71
  1738.                "Third-Maple intersection"
  1739.            )
  1740.           (
  1741. "You are at the intersection of Third Street and Oaktree Ave."  ;72
  1742.                "Third-Oaktree intersection"
  1743.            )
  1744.           (
  1745. "You are at the intersection of Third Street and Vermont Ave."  ;73
  1746.                "Third-Vermont intersection"
  1747.            )
  1748.           (
  1749. "You are at the north end of Third Street at Sycamore Ave."  ;74
  1750.                "Third-Sycamore intersection"
  1751.            )
  1752.           (
  1753. "You are at the south end of Fourth Street at Maple Ave."  ;75
  1754.                "Fourth-Maple intersection"
  1755.            )
  1756.           (
  1757. "You are at the intersection of Fourth Street and Oaktree Ave."  ;76
  1758.                "Fourth-Oaktree intersection"
  1759.            )
  1760.           (
  1761. "You are at the intersection of Fourth Street and Vermont Ave."  ;77
  1762.                "Fourth-Vermont intersection"
  1763.            )
  1764.           (
  1765. "You are at the north end of Fourth Street at Sycamore Ave."  ;78
  1766.                "Fourth-Sycamore intersection"
  1767.            )
  1768.           (
  1769. "You are at the south end of Fifth Street at the east end of Maple Ave."  ;79
  1770.                "Fifth-Maple intersection"
  1771.            )
  1772.           (
  1773. "You are at the intersection of Fifth Street and the east end of Oaktree Ave.
  1774. There is a cliff off to the east."
  1775.                "Fifth-Oaktree intersection"  ;80
  1776.            )
  1777.           (
  1778. "You are at the intersection of Fifth Street and the east end of Vermont Ave."
  1779.                "Fifth-Vermont intersection"  ;81
  1780.            )
  1781.           (
  1782. "You are at the north end of Fifth Street and the east end of Sycamore Ave."
  1783.                "Fifth-Sycamore intersection"  ;82
  1784.            )
  1785.           (
  1786. "You are in front of the Museum of Natural History.  A door leads into
  1787. the building to the north, and a road leads to the southeast."
  1788.                "Museum entrance"                  ;83
  1789.            )
  1790.           (
  1791. "You are in the main lobby for the Museum of Natural History.  In the center
  1792. of the room is the huge skeleton of a dinosaur.  Doors lead out to the
  1793. south and east." 
  1794.                "Museum lobby"                     ;84
  1795.            )
  1796.           (
  1797. "You are in the geological display.  All of the objects that used to
  1798. be on display are missing.  There are rooms to the east, west, and 
  1799. north."
  1800.                "Geological display"               ;85
  1801.            )
  1802.           (
  1803. "You are in the marine life area.  The room is filled with fish tanks,
  1804. which are filled with dead fish that have apparently died due to
  1805. starvation.  Doors lead out to the south and east."
  1806.                "Marine life area"                   ;86
  1807.            )
  1808.           (
  1809. "You are in some sort of maintenance room for the museum.  There is a
  1810. switch on the wall labeled 'BL'.  There are doors to the west and north."
  1811.                "Maintenance room"                   ;87
  1812.            )
  1813.           (
  1814. "You are in a classroom where school children were taught about natural
  1815. history.  On the blackboard is written, 'No children allowed downstairs.'
  1816. There is a door to the east with an 'exit' sign on it.  There is another
  1817. door to the west."
  1818.                "Classroom"                          ;88
  1819.            )
  1820.           (
  1821. "You are at the Vermont St. subway station.  A train is sitting here waiting."
  1822.                "Vermont station"                    ;89
  1823.            )
  1824.           (
  1825. "You are at the Museum subway stop.  A passage leads off to the north."
  1826.                "Museum station"                     ;90
  1827.            )
  1828.           (
  1829. "You are in a north/south tunnel."
  1830.                "N/S tunnel"                          ;91
  1831.            )
  1832.           (
  1833. "You are at the north end of a north/south tunnel.  Stairs lead up and
  1834. down from here.  There is a garbage disposal here."
  1835.                "North end of n/s tunnel"             ;92
  1836.                )
  1837.           (
  1838. "You are at the top of some stairs near the subway station.  There is
  1839. a door to the west."
  1840.                "Top of subway stairs"           ;93
  1841.            )
  1842.           (
  1843. "You are at the bottom of some stairs near the subway station.  There is
  1844. a room to the northeast."
  1845.                "Bottom of subway stairs"       ;94
  1846.            )
  1847.           (
  1848. "You are in another computer room.  There is a computer in here larger
  1849. than you have ever seen.  It has no manufacturers name on it, but it
  1850. does have a sign that says: This machine's name is 'endgame'.  The
  1851. exit is to the southwest.  There is no console here on which you could
  1852. type."
  1853.                "Endgame computer room"         ;95
  1854.            )
  1855.           (
  1856. "You are in a north/south hallway."
  1857.                "Endgame n/s hallway"           ;96
  1858.            )
  1859.           (
  1860. "You have reached a question room.  You must answer a question correctly in
  1861. order to get by.  Use the 'answer' command to answer the question."
  1862.                "Question room 1"              ;97
  1863.            )
  1864.           (
  1865. "You are in a north/south hallway."
  1866.                "Endgame n/s hallway"           ;98
  1867.            )
  1868.           (
  1869. "You are in a second question room."
  1870.                "Question room 2"               ;99
  1871.            )
  1872.           (
  1873. "You are in a north/south hallway."
  1874.                "Endgame n/s hallway"           ;100
  1875.            )
  1876.           (
  1877. "You are in a third question room."
  1878.                "Question room 3"               ;101
  1879.            )
  1880.           (
  1881. "You are in the endgame treasure room.  A door leads out to the north, and
  1882. a hallway leads to the south."
  1883.                "Endgame treasure room"         ;102
  1884.            )
  1885.           (
  1886. "You are in the winner's room.  A door leads back to the south."
  1887.                "Winner's room"                 ;103
  1888.            )
  1889.           (
  1890. "You have reached a dead end.  There is a PC on the floor here.  Above
  1891. it is a sign that reads:
  1892.           Type the 'reset' command to type on the PC. 
  1893. A hole leads north."
  1894.                "PC area"                       ;104
  1895.                )            
  1896. ))
  1897.  
  1898. (setq dun-light-rooms '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 24 25 26 27 28 58 59
  1899.              60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
  1900.              77 78 79 80 81 82 83))
  1901.  
  1902. (setq dun-verblist '((die . dun-die) (ne . dun-ne) (north . dun-n) 
  1903.              (south . dun-s) (east . dun-e) (west . dun-w)
  1904.              (u . dun-up) (d . dun-down) (i . dun-inven)
  1905.              (inventory . dun-inven) (look . dun-examine) (n . dun-n)
  1906.              (s . dun-s) (e . dun-e) (w . dun-w) (se . dun-se)
  1907.              (nw . dun-nw) (sw . dun-sw) (up . dun-up) 
  1908.              (down . dun-down) (in . dun-in) (out . dun-out)
  1909.              (go . dun-go) (drop . dun-drop) (southeast . dun-se)
  1910.              (southwest . dun-sw) (northeast . dun-ne)
  1911.              (northwest . dun-nw) (save . dun-save-game)
  1912.              (restore . dun-restore) (long . dun-long) (dig . dun-dig)
  1913.              (shake . dun-shake) (wave . dun-shake)
  1914.              (examine . dun-examine) (describe . dun-examine) 
  1915.              (climb . dun-climb) (eat . dun-eat) (put . dun-put)
  1916.              (type . dun-type)  (insert . dun-put)
  1917.              (score . dun-score) (help . dun-help) (quit . dun-quit) 
  1918.              (read . dun-examine) (verbose . dun-long) 
  1919.              (urinate . dun-piss) (piss . dun-piss)
  1920.              (flush . dun-flush) (sleep . dun-sleep) (lie . dun-sleep) 
  1921.              (x . dun-examine) (break . dun-break) (drive . dun-drive)
  1922.              (board . dun-in) (enter . dun-in) (turn . dun-turn)
  1923.              (press . dun-press) (push . dun-press) (swim . dun-swim)
  1924.              (on . dun-in) (off . dun-out) (chop . dun-break)
  1925.              (switch . dun-press) (cut . dun-break) (exit . dun-out)
  1926.              (leave . dun-out) (reset . dun-power) (flick . dun-press)
  1927.              (superb . dun-superb) (answer . dun-answer)
  1928.              (throw . dun-drop) (l . dun-examine) (take . dun-take)
  1929.              (get . dun-take) (feed . dun-feed)))
  1930.  
  1931. (setq dun-inbus nil)
  1932. (setq dun-nomail nil)
  1933. (setq dun-ignore '(the to at))
  1934. (setq dun-mode 'moby)
  1935. (setq dun-sauna-level 0)
  1936.  
  1937. (defconst north 0)
  1938. (defconst south 1)
  1939. (defconst east 2)
  1940. (defconst west 3)
  1941. (defconst northeast 4)
  1942. (defconst southeast 5)
  1943. (defconst northwest 6)
  1944. (defconst southwest 7)
  1945. (defconst up 8)
  1946. (defconst down 9)
  1947. (defconst in 10)
  1948. (defconst out 11)
  1949.  
  1950. (setq dungeon-map '(
  1951. ;              no  so  ea  we  ne  se  nw  sw  up  do  in  ot
  1952.             ( 96  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;0
  1953.             ( -1  -1   2  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;1
  1954.             ( -1  -1   3   1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;2
  1955.             ( -1  -1  -1   2   4   6  -1  -1  -1  -1  -1  -1 ) ;3
  1956.             ( -1  -1  -1  -1   5  -1  -1   3  -1  -1  -1  -1 ) ;4
  1957.             ( -1  -1  -1  -1  255 -1  -1   4  -1  -1  255 -1 ) ;5
  1958.             ( -1  -1  -1  -1  -1   7   3  -1  -1  -1  -1  -1 ) ;6
  1959.             ( -1  -1  -1  -1  -1  255  6  27  -1  -1  -1  -1 ) ;7
  1960.             ( 255  5   9  10  -1  -1  -1   5  -1  -1  -1   5 ) ;8
  1961.             ( -1  -1  -1   8  -1  -1  -1  -1  -1  -1  -1  -1 ) ;9
  1962.             ( -1  -1   8  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;10
  1963.             ( -1   8  -1  58  -1  -1  -1  -1  -1  -1  -1  -1 ) ;11
  1964.             ( -1  -1  13  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;12
  1965.             ( 15  -1  14  12  -1  -1  -1  -1  -1  -1  -1  -1 ) ;13
  1966.             ( -1  -1  -1  13  -1  -1  -1  -1  -1  -1  -1  -1 ) ;14
  1967.             ( -1  13  16  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;15
  1968.             ( -1  -1  -1  15  -1  -1  -1  -1  -1  17  16  -1 ) ;16
  1969.             ( -1  -1  17  17  17  17 255  17 255  17  -1  -1 ) ;17
  1970.             ( 18  18  18  18  18  -1  18  18  19  18  -1  -1 ) ;18
  1971.             ( -1  18  18  19  19  20  19  19  -1  18  -1  -1 ) ;19
  1972.             ( -1  -1  -1  18  -1  -1  -1  -1  -1  21  -1  -1 ) ;20
  1973.             ( -1  -1  -1  -1  -1  20  22  -1  -1  -1  -1  -1 ) ;21
  1974.             ( 18  18  18  18  16  18  23  18  18  18  18  18 ) ;22
  1975.             ( -1 255  -1  -1  -1  19  -1  -1  -1  -1  -1  -1 ) ;23
  1976.             ( 23  25  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;24
  1977.             ( 24 255  -1  -1  -1  -1  -1  -1  -1  -1 255  -1 ) ;25
  1978.             (255  28  -1  -1  -1  -1  -1  -1  -1  -1 255  -1 ) ;26
  1979.             ( -1  -1  -1  -1   7  -1  -1  -1  -1  -1  -1  -1 ) ;27
  1980.             ( 26 255  -1  -1  -1  -1  -1  -1  -1  -1  255 -1 ) ;28
  1981.             ( -1  -1  30  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;29
  1982.             ( -1  -1  31  29  -1  -1  -1  -1  -1  -1  -1  -1 ) ;30
  1983.             ( 32  33  -1  30  -1  -1  -1  -1  -1  -1  -1  -1 ) ;31
  1984.             ( -1  31  -1  255 -1  -1  -1  -1  -1  34  -1  -1 ) ;32
  1985.             ( 31  -1  -1  -1  -1  -1  -1  -1  -1  35  -1  -1 ) ;33
  1986.             ( -1  35  -1  -1  -1  -1  -1  -1  32  37  -1  -1 ) ;34
  1987.             ( 34  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;35
  1988.             ( -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;36
  1989.             ( -1  -1  -1  -1  -1  -1  -1  38  34  -1  -1  -1 ) ;37
  1990.             ( -1  -1  40  41  37  -1  -1  39  -1  -1  -1  -1 ) ;38
  1991.             ( -1  -1  -1  -1  38  -1  -1  -1  -1  -1  -1  -1 ) ;39
  1992.             ( -1  -1  -1  38  -1  -1  -1  -1  42  -1  -1  -1 ) ;40
  1993.             ( -1  -1  38  -1  -1  -1  -1  -1  -1  43  -1  -1 ) ;41
  1994.             ( -1  -1  -1  -1  -1  -1  -1  -1  -1  40  -1  -1 ) ;42
  1995.             ( 44  -1  46  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;43
  1996.             ( -1  43  45  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;44
  1997.             ( -1  46  -1  44  -1  -1  -1  -1  -1  -1  -1  -1 ) ;45
  1998.             ( 45  -1  -1  43  -1  -1  -1  -1  -1  255 -1  -1 ) ;46
  1999.             ( 48  50  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;47
  2000.             ( 49  47  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;48
  2001.             ( -1  48  -1  -1  -1  -1  -1  -1  52  -1  -1  -1 ) ;49
  2002.             ( 47  51  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;50
  2003.             ( 50  104 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;51
  2004.             ( -1  -1  -1  -1  -1  -1  -1  -1  53  49  -1  -1 ) ;52
  2005.             ( -1  -1  -1  -1  -1  -1  -1  -1  54  52  -1  -1 ) ;53
  2006.             ( -1  -1  -1  -1  55  -1  -1  -1  -1  53  -1  -1 ) ;54
  2007.             ( -1  -1  -1  -1  56  -1  -1  54  -1  -1  -1  54 ) ;55
  2008.             ( -1  -1  -1  -1  -1  -1  -1  55  -1  31  -1  -1 ) ;56
  2009.             ( -1  -1  32  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;57
  2010.             ( 59  -1  11  -1  -1  -1  -1  -1  -1  -1  255 255) ;58
  2011.             ( 60  58  63  -1  -1  -1  255 -1  -1  -1  255 255) ;59
  2012.             ( 61  59  64  -1  -1  -1  -1  -1  -1  -1  255 255) ;60
  2013.             ( 62  60  65  -1  -1  -1  -1  -1  -1  -1  255 255) ;61
  2014.             ( -1  61  66  -1  -1  -1  -1  -1  -1  -1  255 255) ;62
  2015.             ( 64  -1  67  59  -1  -1  -1  -1  -1  -1  255 255) ;63
  2016.             ( 65  63  68  60  -1  -1  -1  -1  -1  -1  255 255) ;64
  2017.             ( 66  64  69  61  -1  -1  -1  -1  -1  -1  255 255) ;65
  2018.             ( -1  65  70  62  -1  -1  -1  -1  -1  -1  255 255) ;66
  2019.             ( 68  -1  71  63  -1  -1  -1  -1  -1  -1  255 255) ;67
  2020.             ( 69  67  72  64  -1  -1  -1  -1  -1  -1  255 255) ;68
  2021.             ( 70  68  73  65  -1  -1  -1  -1  -1  -1  255 255) ;69
  2022.             ( -1  69  74  66  -1  -1  -1  -1  -1  -1  255 255) ;70
  2023.             ( 72  -1  75  67  -1  -1  -1  -1  -1  -1  255 255) ;71
  2024.             ( 73  71  76  68  -1  -1  -1  -1  -1  -1  255 255) ;72
  2025.             ( 74  72  77  69  -1  -1  -1  -1  -1  -1  255 255) ;73
  2026.             ( -1  73  78  70  -1  -1  -1  -1  -1  -1  255 255) ;74
  2027.             ( 76  -1  79  71  -1  -1  -1  -1  -1  -1  255 255) ;75
  2028.             ( 77  75  80  72  -1  -1  -1  -1  -1  -1  255 255) ;76
  2029.             ( 78  76  81  73  -1  -1  -1  -1  -1  -1  255 255) ;77
  2030.             ( -1  77  82  74  -1  -1  -1  -1  -1  -1  255 255) ;78
  2031.             ( 80  -1  -1  75  -1  -1  -1  -1  -1  -1  255 255) ;79
  2032.             ( 81  79  255 76  -1  -1  -1  -1  -1  -1  255 255) ;80
  2033.             ( 82  80  -1  77  -1  -1  -1  -1  -1  -1  255 255) ;81
  2034.             ( -1  81  -1  78  -1  -1  -1  -1  -1  -1  255 255) ;82
  2035.             ( 84  -1  -1  -1  -1  59  -1  -1  -1  -1  255 255) ;83
  2036.             ( -1  83  85  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;84
  2037.             ( 86  -1  87  84  -1  -1  -1  -1  -1  -1  -1  -1 ) ;85
  2038.             ( -1  85  88  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;86
  2039.             ( 88  -1  -1  85  -1  -1  -1  -1  -1  -1  -1  -1 ) ;87
  2040.             ( -1  87 255  86  -1  -1  -1  -1  -1  -1  -1  -1 ) ;88
  2041.             ( -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 255  -1 ) ;89
  2042.             ( 91  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;90
  2043.             ( 92  90  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;91
  2044.             ( -1  91  -1  -1  -1  -1  -1  -1  93  94  -1  -1 ) ;92
  2045.             ( -1  -1  -1  88  -1  -1  -1  -1  -1  92  -1  -1 ) ;93
  2046.             ( -1  -1  -1  -1  95  -1  -1  -1  92  -1  -1  -1 ) ;94
  2047.             ( -1  -1  -1  -1  -1  -1  -1  94  -1  -1  -1  -1 ) ;95
  2048.             ( 97   0  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;96
  2049.             ( -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;97
  2050.             ( 99  97  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;98
  2051.             ( -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;99
  2052.             ( 101 99  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;100
  2053.             ( -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;101
  2054.             ( 103 101 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;102
  2055.             ( -1  102 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;103
  2056.             ( 51  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 ) ;104
  2057.             )
  2058. ;              no  so  ea  we  ne  se  nw  sw  up  do  in  ot
  2059. )
  2060.  
  2061.  
  2062. ;;; How the user references *all* objects, permanent and regular.
  2063. (setq dun-objnames '(
  2064.          (shovel . 0) 
  2065.          (lamp . 1)
  2066.          (cpu . 2) (board . 2) (card . 2)
  2067.          (food . 3) 
  2068.          (key . 4) 
  2069.          (paper . 5)
  2070.          (rms . 6) (statue . 6) (statuette . 6)  (stallman . 6)
  2071.          (diamond . 7)
  2072.          (weight . 8)
  2073.          (life . 9) (preserver . 9)
  2074.          (bracelet . 10) (emerald . 10) 
  2075.          (gold . 11)
  2076.          (platinum . 12)
  2077.          (towel . 13) (beach . 13)
  2078.          (axe . 14)
  2079.          (silver . 15)
  2080.          (license . 16)
  2081.          (coins . 17)
  2082.          (egg . 18)
  2083.          (jar . 19)
  2084.          (bone . 20)
  2085.          (acid . 21) (nitric . 21)
  2086.          (glycerine . 22)
  2087.          (ruby . 23)
  2088.          (amethyst . 24) 
  2089.          (mona . 25)
  2090.          (bill . 26) 
  2091.          (floppy . 27) (disk . 27)
  2092.          
  2093.          (boulder . -1)
  2094.          (tree . -2) (trees . -2) 
  2095.          (bear . -3)
  2096.          (bin . -4) (bins . -4)
  2097.          (cabinet . -5) (computer . -5) (vax . -5) (ibm . -5) 
  2098.          (protoplasm . -6)
  2099.          (dial . -7) 
  2100.          (button . -8) 
  2101.          (chute . -9) 
  2102.          (painting . -10)
  2103.          (bed . -11)
  2104.          (urinal . -12)
  2105.          (URINE . -13)
  2106.          (pipes . -14) (pipe . -14) 
  2107.          (box . -15) (slit . -15) 
  2108.          (cable . -16) (ethernet . -16) 
  2109.          (mail . -17) (drop . -17)
  2110.          (bus . -18)
  2111.          (gate . -19)
  2112.          (cliff . -20) 
  2113.          (skeleton . -21) (dinosaur . -21)
  2114.          (fish . -22)
  2115.          (tanks . -23)
  2116.          (switch . -24)
  2117.          (blackboard . -25)
  2118.          (disposal . -26) (garbage . -26)
  2119.          (ladder . -27)
  2120.          (subway . -28) (train . -28) 
  2121.          (pc . -29) (drive . -29)
  2122. ))
  2123.  
  2124. (dolist (x dun-objnames)
  2125.   (let (name)
  2126.     (setq name (concat "obj-" (prin1-to-string (car x))))
  2127.     (eval (list 'defconst (intern name) (cdr x)))))
  2128.  
  2129. (defconst obj-special 255)
  2130.  
  2131. ;;; The initial setup of what objects are in each room.
  2132. ;;; Regular objects have whole numbers lower than 255.
  2133. ;;; Objects that cannot be taken but might move and are
  2134. ;;; described during room description are negative.
  2135. ;;; Stuff that is described and might change are 255, and are
  2136. ;;; handled specially by 'dun-describe-room. 
  2137.  
  2138. (setq dun-room-objects (list nil 
  2139.  
  2140.         (list obj-shovel)                     ;; treasure-room
  2141.         (list obj-boulder)                    ;; dead-end
  2142.         nil nil nil
  2143.         (list obj-food)                       ;; se-nw-road
  2144.         (list obj-bear)                       ;; bear-hangout
  2145.         nil nil
  2146.         (list obj-special)                    ;; computer-room
  2147.         (list obj-lamp obj-license obj-silver);; meadow
  2148.         nil nil
  2149.         (list obj-special)                    ;; sauna
  2150.         nil 
  2151.         (list obj-weight obj-life)            ;; weight-room
  2152.         nil nil
  2153.         (list obj-rms obj-floppy)             ;; thirsty-maze
  2154.         nil nil nil nil nil nil nil 
  2155.         (list obj-emerald)                    ;; hidden-area
  2156.         nil
  2157.         (list obj-gold)                       ;; misty-room
  2158.         nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
  2159.         (list obj-towel obj-special)          ;; red-room
  2160.         nil nil nil nil nil
  2161.         (list obj-box)                        ;; stair-landing
  2162.         nil nil nil
  2163.         (list obj-axe)                        ;; smal-crawlspace
  2164.         nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
  2165.         nil nil nil nil nil
  2166.         (list obj-special)                    ;; fourth-vermont-intersection
  2167.         nil nil
  2168.         (list obj-coins)                      ;; fifth-oaktree-intersection
  2169.         nil
  2170.         (list obj-bus)                        ;; fifth-sycamore-intersection
  2171.         nil
  2172.         (list obj-bone)                       ;; museum-lobby
  2173.         nil
  2174.         (list obj-jar obj-special obj-ruby)   ;; marine-life-area
  2175.         (list obj-nitric)                     ;; maintenance-room
  2176.         (list obj-glycerine)                  ;; classroom
  2177.         nil nil nil nil nil
  2178.         (list obj-amethyst)                   ;; bottom-of-subway-stairs
  2179.         nil nil
  2180.         (list obj-special)                    ;; question-room-1
  2181.         nil
  2182.         (list obj-special)                    ;; question-room-2
  2183.         nil
  2184.         (list obj-special)                    ;; question-room-three
  2185.         nil
  2186.         (list obj-mona)                       ;; winner's-room
  2187. nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
  2188. nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
  2189. nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
  2190. nil))
  2191.  
  2192. ;;; These are objects in a room that are only described in the
  2193. ;;; room description.  They are permanent.
  2194.  
  2195. (setq dun-room-silents (list nil
  2196.         (list obj-tree)                        ;; dead-end
  2197.         (list obj-tree)                        ;; e-w-dirt-road
  2198.         nil nil nil nil nil nil
  2199.         (list obj-bin)                         ;; mailroom
  2200.         (list obj-computer)                    ;; computer-room
  2201.         nil nil nil
  2202.         (list obj-dial)                        ;; sauna
  2203.         nil
  2204.         (list obj-ladder)                      ;; weight-room
  2205.         (list obj-button obj-ladder)           ;; maze-button-room
  2206.         nil nil nil
  2207.         nil nil nil nil nil nil nil
  2208.         (list obj-chute)                       ;; cave-entrance
  2209.         nil nil nil nil nil
  2210.         (list obj-painting obj-bed)            ;; bedroom
  2211.         (list obj-urinal obj-pipes)            ;; bathroom
  2212.         nil nil nil nil nil nil
  2213.         (list obj-boulder)                     ;; horseshoe-boulder-room
  2214.         nil nil nil nil nil nil nil nil nil nil nil nil nil nil
  2215.         (list obj-computer obj-cable)          ;; gamma-computing-center
  2216.         (list obj-mail)                        ;; post-office
  2217.         (list obj-gate)                        ;; main-maple-intersection
  2218.         nil nil nil nil nil nil nil nil nil nil nil nil nil
  2219.         nil nil nil nil nil nil nil
  2220.         (list obj-cliff)                       ;; fifth-oaktree-intersection
  2221.         nil nil nil
  2222.         (list obj-dinosaur)                    ;; museum-lobby
  2223.         nil
  2224.         (list obj-fish obj-tanks)              ;; marine-life-area
  2225.         (list obj-switch)                      ;; maintenance-room
  2226.         (list obj-blackboard)                  ;; classroom
  2227.         (list obj-train)                       ;; vermont-station
  2228.         nil nil
  2229.         (list obj-disposal)                    ;; north-end-of-n-s-tunnel
  2230.         nil nil
  2231.         (list obj-computer)                    ;; endgame-computer-room
  2232.         nil nil nil nil nil nil nil nil 
  2233.     (list obj-pc)                          ;; pc-area
  2234.     nil nil nil nil nil nil
  2235. ))
  2236. (setq dun-inventory '(1))
  2237.  
  2238. ;;; Descriptions of objects, as they appear in the room description, and
  2239. ;;; the inventory.
  2240.  
  2241. (setq dun-objects '(
  2242.         ("There is a shovel here." "A shovel")                ;0
  2243.         ("There is a lamp nearby." "A lamp")                  ;1
  2244.         ("There is a CPU card here." "A computer board")      ;2
  2245.         ("There is some food here." "Some food")              ;3
  2246.         ("There is a shiny brass key here." "A brass key")    ;4
  2247.         ("There is a slip of paper here." "A slip of paper")  ;5
  2248.         ("There is a wax statuette of Richard Stallman here." ;6
  2249.          "An RMS statuette")
  2250.         ("There is a shimmering diamond here." "A diamond")   ;7
  2251.         ("There is a 10 pound weight here." "A weight")       ;8
  2252.         ("There is a life preserver here." "A life preserver");9
  2253.         ("There is an emerald bracelet here." "A bracelet")   ;10
  2254.         ("There is a gold bar here." "A gold bar")            ;11
  2255.         ("There is a platinum bar here." "A platinum bar")    ;12
  2256.         ("There is a beach towel on the ground here." "A beach towel")
  2257.         ("There is an axe here." "An axe") ;14
  2258.         ("There is a silver bar here." "A silver bar")  ;15
  2259.         ("There is a bus driver's license here." "A license") ;16
  2260.         ("There are some valuable coins here." "Some valuable coins")
  2261.         ("There is a jewel-encrusted egg here." "A valuable egg") ;18
  2262.         ("There is a glass jar here." "A glass jar") ;19
  2263.         ("There is a dinosaur bone here." "A bone") ;20
  2264.         ("There is a packet of nitric acid here." "Some nitric acid")
  2265.         ("There is a packet of glycerine here." "Some glycerine") ;22
  2266.         ("There is a valuable ruby here." "A ruby") ;23
  2267.         ("There is a valuable amethyst here." "An amethyst") ;24
  2268.         ("The Mona Lisa is here." "The Mona Lisa") ;25
  2269.         ("There is a 100 dollar bill here." "A $100 bill") ;26
  2270.         ("There is a floppy disk here." "A floppy disk") ;27
  2271.            )
  2272. )
  2273.  
  2274. ;;; Weight of objects
  2275.  
  2276. (setq dun-object-lbs 
  2277.       '(2 1 1 1 1 0 2 2 10 3 1 1 1 0 1 1 0 1 1 1 1 0 0 2 2 1 0 0))
  2278. (setq dun-object-pts 
  2279.       '(0 0 0 0 0 0 0 10 0 0 10 10 10 0 0 10 0 10 10 0 0 0 0 10 10 10 10 0))
  2280.  
  2281.  
  2282. ;;; Unix representation of objects.
  2283. (setq dun-objfiles '(
  2284.          "shovel.o" "lamp.o" "cpu.o" "food.o" "key.o" "paper.o"
  2285.          "rms.o" "diamond.o" "weight.o" "preserver.o" "bracelet.o"
  2286.          "gold.o" "platinum.o" "towel.o" "axe.o" "silver.o" "license.o"
  2287.          "coins.o" "egg.o" "jar.o" "bone.o" "nitric.o" "glycerine.o"
  2288.          "ruby.o" "amethyst.o"
  2289.          ))
  2290.  
  2291. ;;; These are the descriptions for the negative numbered objects from
  2292. ;;; dun-room-objects
  2293.  
  2294. (setq dun-perm-objects '(
  2295.              nil
  2296.              ("There is a large boulder here.")
  2297.              nil
  2298.              ("There is a ferocious bear here!")
  2299.              nil
  2300.              nil
  2301.              ("There is a worthless pile of protoplasm here.")
  2302.              nil
  2303.              nil
  2304.              nil
  2305.              nil
  2306.              nil
  2307.              nil
  2308.              ("There is a strange smell in this room.")
  2309.              nil
  2310.              (
  2311. "There is a box with a slit in it, bolted to the wall here."
  2312.                      )
  2313.              nil
  2314.              nil
  2315.              ("There is a bus here.")
  2316.              nil
  2317.              nil
  2318.              nil
  2319. ))
  2320.  
  2321.  
  2322. ;;; These are the descriptions the user gets when regular objects are
  2323. ;;; examined.
  2324.  
  2325. (setq dun-physobj-desc '(
  2326. "It is a normal shovel with a price tag attached that says $19.99."
  2327. "The lamp is hand-crafted by Geppetto."
  2328. "The CPU board has a VAX chip on it.  It seems to have
  2329. 2 Megabytes of RAM onboard."
  2330. "It looks like some kind of meat.  Smells pretty bad."
  2331. nil
  2332. "The paper says: Don't forget to type 'help' for help.  Also, remember
  2333. this word: 'worms'"
  2334. "The statuette is of the likeness of Richard Stallman, the author of the
  2335. famous EMACS editor.  You notice that he is not wearing any shoes."
  2336. nil
  2337. "You observe that the weight is heavy."
  2338. "It says S. S. Minnow."
  2339. nil
  2340. nil
  2341. nil
  2342. "It has a picture of snoopy on it."
  2343. nil
  2344. nil
  2345. "It has your picture on it!"
  2346. "They are old coins from the 19th century."
  2347. "It is a valuable Fabrege egg."
  2348. "It is a a plain glass jar."
  2349. nil
  2350. nil
  2351. nil
  2352. nil
  2353. nil
  2354.                      )
  2355. )
  2356.  
  2357. ;;; These are the descriptions the user gets when non-regular objects
  2358. ;;; are examined.
  2359.  
  2360. (setq dun-permobj-desc '(
  2361.              nil
  2362. "It is just a boulder.  It cannot be moved."
  2363. "They are palm trees with a bountiful supply of coconuts in them."
  2364. "It looks like a grizzly to me."
  2365. "All of the bins are empty.  Looking closely you can see that there
  2366. are names written at the bottom of each bin, but most of them are
  2367. faded away so that you cannot read them.  You can only make out three
  2368. names:
  2369.                    Jeffrey Collier
  2370.                    Robert Toukmond
  2371.                    Thomas Stock
  2372. "
  2373.                       nil
  2374. "It is just a garbled mess."
  2375. "The dial points to a temperature scale which has long since faded away."
  2376. nil
  2377. nil
  2378. "It is a velvet painting of Elvis Presly.  It seems to be nailed to the
  2379. wall, and you cannot move it."
  2380. "It is a queen sized bed, with a very firm mattress."
  2381. "The urinal is very clean compared with everything else in the cave.  There
  2382. isn't even any rust.  Upon close examination you realize that the drain at the
  2383. bottom is missing, and there is just a large hole leading down the
  2384. pipes into nowhere.  The hole is too small for a person to fit in.  The 
  2385. flush handle is so clean that you can see your reflection in it."
  2386. nil
  2387. nil
  2388. "The box has a slit in the top of it, and on it, in sloppy handwriting, is
  2389. written: 'For key upgrade, put key in here.'"
  2390. nil
  2391. "It says 'express mail' on it."
  2392. "It is a 35 passenger bus with the company name 'mobytours' on it."
  2393. "It is a large metal gate that is too big to climb over."
  2394. "It is a HIGH cliff."
  2395. "Unfortunately you do not know enough about dinosaurs to tell very much about
  2396. it.  It is very big, though."
  2397. "The fish look like they were once quite beautiful."
  2398. nil
  2399. nil
  2400. nil
  2401. nil
  2402. "It is a normal ladder that is permanently attached to the hole."
  2403. "It is a passenger train that is ready to go."
  2404. "It is a personal computer that has only one floppy disk drive."
  2405.             )
  2406. )
  2407.  
  2408. (setq dun-diggables 
  2409.       (list nil nil nil (list obj-cpu) nil nil nil nil nil nil nil
  2410.           nil nil nil nil nil nil nil nil nil nil      ;11-20
  2411.           nil nil nil nil nil nil nil nil nil nil      ;21-30
  2412.           nil nil nil nil nil nil nil nil nil nil      ;31-40
  2413.           nil (list obj-platinum) nil nil nil nil nil nil nil nil))
  2414.  
  2415. (setq scroll-step 2)
  2416.  
  2417. (setq dun-room-shorts nil)
  2418. (dolist (x dun-rooms)
  2419.   (setq dun-room-shorts  
  2420.              (append dun-room-shorts (list (downcase 
  2421.                             (dun-space-to-hyphen
  2422.                              (cadr x)))))))
  2423.  
  2424. (setq dun-endgame-questions '(
  2425.               (
  2426. "What is your password on the machine called 'pokey'?" "robert")
  2427.               (
  2428. "What password did you use during anonymous ftp to gamma?" "foo")
  2429.               (
  2430. "Excluding the endgame, how many places are there where you can put
  2431. treasures for points?" "4" "four")
  2432.               (
  2433. "What is your login name on the 'endgame' machine?" "toukmond"
  2434. )
  2435.               (
  2436. "What is the nearest whole dollar to the price of the shovel?" "20" "twenty")
  2437.               (
  2438. "What is the name of the bus company serving the town?" "mobytours")
  2439.               (
  2440. "Give either of the two last names in the mailroom, other than your own."
  2441. "collier" "stock")
  2442.               (
  2443. "What cartoon character is on the towel?" "snoopy")
  2444.               (
  2445. "What is the last name of the author of EMACS?" "stallman")
  2446.               (
  2447. "How many megabytes of memory is on the CPU board for the Vax?" "2")
  2448.               (
  2449. "Which street in town is named after a U.S. state?" "vermont")
  2450.               (
  2451. "How many pounds did the weight weigh?" "ten" "10")
  2452.               (
  2453. "Name the STREET which runs right over the subway stop." "fourth" "4" "4th")
  2454.               (
  2455. "How many corners are there in town (excluding the one with the Post Office)?"
  2456.                   "24" "twentyfour" "twenty-four")
  2457.               (
  2458. "What type of bear was hiding your key?" "grizzly")
  2459.               (
  2460. "Name either of the two objects you found by digging." "cpu" "card" "vax"
  2461. "board" "platinum")
  2462.               (
  2463. "What network protocol is used between pokey and gamma?" "tcp/ip" "ip" "tcp")
  2464. ))
  2465.  
  2466. (let (a)
  2467.   (setq a 0)
  2468.   (dolist (x dun-room-shorts)
  2469.     (eval (list 'defconst (intern x) a))
  2470.     (setq a (+ a 1))))
  2471.  
  2472.  
  2473.  
  2474. ;;;;
  2475. ;;;; This section defines the UNIX emulation functions for dunnet.
  2476. ;;;;
  2477.  
  2478. (defun dun-unix-parse (args)
  2479.   (interactive "*p")
  2480.   (beginning-of-line)
  2481.   (let (beg esign)
  2482.     (setq beg (+ (point) 2))
  2483.     (end-of-line)
  2484.     (if (and (not (= beg (point)))
  2485.          (string= "$" (buffer-substring (- beg 2) (- beg 1))))
  2486.     (progn
  2487.       (setq line (downcase (buffer-substring beg (point))))
  2488.       (princ line)
  2489.       (if (eq (dun-parse2 nil dun-unix-verbs line) -1)
  2490.           (progn
  2491.         (if (setq esign (string-match "=" line))
  2492.             (dun-doassign line esign)        
  2493.           (dun-mprinc (car line-list))
  2494.           (dun-mprincl ": not found.")))))
  2495.       (goto-char (point-max))
  2496.       (dun-mprinc "\n"))
  2497.     (if (eq dungeon-mode 'unix)
  2498.     (progn
  2499.       (dun-fix-screen)
  2500.       (dun-mprinc "$ ")))))
  2501.  
  2502. (defun dun-doassign (line esign)
  2503.   (if (not dun-wizard)
  2504.       (let (passwd)
  2505.     (dun-mprinc "Enter wizard password: ")
  2506.     (setq passwd (dun-read-line))
  2507.     (if (not dun-batch-mode)
  2508.         (dun-mprinc "\n"))
  2509.     (if (string= passwd "moby")
  2510.         (progn
  2511.           (setq dun-wizard t)
  2512.           (dun-doassign line esign))
  2513.       (dun-mprincl "Incorrect.")))
  2514.  
  2515.     (let (varname epoint afterq i value)
  2516.       (setq varname (substring line 0 esign))
  2517.       (if (not (setq epoint (string-match ")" line)))
  2518.       (if (string= (substring line (1+ esign) (+ esign 2))
  2519.                "\"")
  2520.           (progn
  2521.         (setq afterq (substring line (+ esign 2)))
  2522.         (setq epoint (+
  2523.                   (string-match "\"" afterq)
  2524.                   (+ esign 3))))
  2525.         
  2526.         (if (not (setq epoint (string-match " " line)))
  2527.         (setq epoint (length line))))
  2528.     (setq epoint (1+ epoint))
  2529.     (while (and
  2530.         (not (= epoint (length line)))
  2531.         (setq i (string-match ")" (substring line epoint))))
  2532.       (setq epoint (+ epoint i 1))))
  2533.       (setq value (substring line (1+ esign) epoint))
  2534.       (dun-eval varname value))))
  2535.  
  2536. (defun dun-eval (varname value)
  2537.   (let (eval-error)
  2538.     (switch-to-buffer (get-buffer-create "*dungeon-eval*"))
  2539.     (erase-buffer)
  2540.     (insert "(setq ")
  2541.     (insert varname)
  2542.     (insert " ")
  2543.     (insert value)
  2544.     (insert ")")
  2545.     (setq eval-error nil)
  2546.     (condition-case nil
  2547.     (eval-current-buffer)
  2548.       (error (setq eval-error t)))
  2549.     (kill-buffer (current-buffer))
  2550.     (switch-to-buffer "*dungeon*")
  2551.     (if eval-error
  2552.     (dun-mprincl "Invalid syntax."))))
  2553.   
  2554.  
  2555. (defun dun-unix-interface ()
  2556.   (dun-login)
  2557.   (if dun-logged-in
  2558.       (progn
  2559.     (setq dungeon-mode 'unix)
  2560.     (define-key dungeon-mode-map "\r" 'dun-unix-parse)
  2561.     (dun-mprinc "$ "))))
  2562.  
  2563. (defun dun-login ()
  2564.   (let (tries username password)
  2565.     (setq tries 4)
  2566.     (while (and (not dun-logged-in) (> (setq tries (- tries 1)) 0))
  2567.       (dun-mprinc "\n\nUNIX System V, Release 2.2 (pokey)\n\nlogin: ")
  2568.       (setq username (dun-read-line))
  2569.       (if (not dun-batch-mode)
  2570.       (dun-mprinc "\n"))
  2571.       (dun-mprinc "password: ")
  2572.       (setq password (dun-read-line))
  2573.       (if (not dun-batch-mode)
  2574.       (dun-mprinc "\n"))
  2575.       (if (or (not (string= username "toukmond"))
  2576.           (not (string= password "robert")))
  2577.       (dun-mprincl "login incorrect")
  2578.     (setq dun-logged-in t)
  2579.     (dun-mprincl "
  2580. Welcome to Unix\n
  2581. Please clean up your directories.  The filesystem is getting full.
  2582. Our tcp/ip link to gamma is a little flakey, but seems to work.
  2583. The current version of ftp can only send files from the current
  2584. directory, and deletes them after they are sent!  Be careful.
  2585.  
  2586. Note: Restricted bourne shell in use.\n")))
  2587.   (setq dungeon-mode 'dungeon)))
  2588.  
  2589. (defun dun-ls (args)
  2590.   (if (car args)
  2591.       (let (ocdpath ocdroom)
  2592.     (setq ocdpath dun-cdpath)
  2593.     (setq ocdroom dun-cdroom)
  2594.     (if (not (eq (dun-cd args) -2))
  2595.         (dun-ls nil))
  2596.     (setq dun-cdpath ocdpath)
  2597.     (setq dun-cdroom ocdroom))
  2598.     (if (= dun-cdroom -10)
  2599.     (dun-ls-inven))
  2600.     (if (= dun-cdroom -2)
  2601.     (dun-ls-rooms))
  2602.     (if (= dun-cdroom -3)
  2603.     (dun-ls-root))
  2604.     (if (= dun-cdroom -4)
  2605.     (dun-ls-usr))
  2606.     (if (> dun-cdroom 0)
  2607.     (dun-ls-room))))
  2608.  
  2609. (defun dun-ls-root ()
  2610.   (dun-mprincl "total 4
  2611. drwxr-xr-x  3 root     staff           512 Jan 1 1970 .
  2612. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..
  2613. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 usr
  2614. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 rooms"))
  2615.  
  2616. (defun dun-ls-usr ()
  2617.   (dun-mprincl "total 4
  2618. drwxr-xr-x  3 root     staff           512 Jan 1 1970 .
  2619. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..
  2620. drwxr-xr-x  3 toukmond restricted      512 Jan 1 1970 toukmond"))
  2621.  
  2622. (defun dun-ls-rooms ()
  2623.   (dun-mprincl "total 16
  2624. drwxr-xr-x  3 root     staff           512 Jan 1 1970 .
  2625. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..")
  2626.   (dolist (x dun-visited)
  2627.     (dun-mprinc
  2628. "drwxr-xr-x  3 root     staff           512 Jan 1 1970 ")
  2629.     (dun-mprincl (nth x dun-room-shorts))))
  2630.  
  2631. (defun dun-ls-room ()
  2632.   (dun-mprincl "total 4
  2633. drwxr-xr-x  3 root     staff           512 Jan 1 1970 .
  2634. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..
  2635. -rwxr-xr-x  3 root     staff          2048 Jan 1 1970 description")
  2636.   (dolist (x (nth dun-cdroom dun-room-objects))
  2637.     (if (and (>= x 0) (not (= x 255)))
  2638.     (progn
  2639.       (dun-mprinc "-rwxr-xr-x  1 toukmond restricted        0 Jan 1 1970 ")
  2640.       (dun-mprincl (nth x dun-objfiles))))))
  2641.  
  2642. (defun dun-ls-inven ()
  2643.   (dun-mprinc "total 467
  2644. drwxr-xr-x  3 toukmond restricted      512 Jan 1 1970 .
  2645. drwxr-xr-x  3 root     staff          2048 Jan 1 1970 ..")
  2646.   (dolist (x dun-unix-verbs)
  2647.     (if (not (eq (car x) 'IMPOSSIBLE))
  2648.     (progn
  2649.       (dun-mprinc"
  2650. -rwxr-xr-x  1 toukmond restricted    10423 Jan 1 1970 ")
  2651.       (dun-mprinc (car x)))))
  2652.   (dun-mprinc "\n")
  2653.   (if (not dun-uncompressed)
  2654.       (dun-mprincl
  2655. "-rwxr-xr-x  1 toukmond restricted        0 Jan 1 1970 paper.o.Z"))
  2656.   (dolist (x dun-inventory)
  2657.     (dun-mprinc 
  2658. "-rwxr-xr-x  1 toukmond restricted        0 Jan 1 1970 ")
  2659.     (dun-mprincl (nth x dun-objfiles))))
  2660.  
  2661. (defun dun-echo (args)
  2662.   (let (nomore var)
  2663.     (setq nomore nil)
  2664.     (dolist (x args)
  2665.         (if (not nomore)
  2666.         (progn
  2667.           (if (not (string= (substring x 0 1) "$"))
  2668.               (progn
  2669.             (dun-mprinc x)
  2670.             (dun-mprinc " "))
  2671.             (setq var (intern (substring x 1)))
  2672.             (if (not (boundp var))
  2673.             (dun-mprinc " ")
  2674.               (if (member var dun-restricted)
  2675.               (progn
  2676.                 (dun-mprinc var)
  2677.                 (dun-mprinc ": Permission denied")
  2678.                 (setq nomore t))
  2679.             (eval (list 'dun-mprinc var))
  2680.             (dun-mprinc " ")))))))
  2681.         (dun-mprinc "\n")))
  2682.  
  2683.  
  2684. (defun dun-ftp (args)
  2685.   (let (host username passwd ident newlist)
  2686.     (if (not (car args))
  2687.     (dun-mprincl "ftp: hostname required on command line.")
  2688.       (setq host (intern (car args)))
  2689.       (if (not (member host '(gamma dun-endgame)))
  2690.       (dun-mprincl "ftp: Unknown host.")
  2691.     (if (eq host 'dun-endgame)
  2692.         (dun-mprincl "ftp: connection to endgame not allowed")
  2693.       (if (not dun-ethernet)
  2694.           (dun-mprincl "ftp: host not responding.")
  2695.         (dun-mprincl "Connected to gamma. FTP ver 0.9 00:00:00 01/01/70")
  2696.         (dun-mprinc "Username: ")
  2697.         (setq username (dun-read-line))
  2698.         (if (string= username "toukmond")
  2699.         (if dun-batch-mode
  2700.             (dun-mprincl "toukmond ftp access not allowed.")
  2701.           (dun-mprincl "\ntoukmond ftp access not allowed."))
  2702.           (if (string= username "anonymous")
  2703.           (if dun-batch-mode
  2704.               (dun-mprincl
  2705.                "Guest login okay, send your user ident as password.")
  2706.             (dun-mprincl 
  2707.              "\nGuest login okay, send your user ident as password."))
  2708.         (if dun-batch-mode
  2709.             (dun-mprinc "Password required for ")
  2710.           (dun-mprinc "\nPassword required for "))
  2711.         (dun-mprincl username))
  2712.           (dun-mprinc "Password: ")
  2713.           (setq ident (dun-read-line))
  2714.           (if (not (string= username "anonymous"))
  2715.           (if dun-batch-mode
  2716.               (dun-mprincl "Login failed.")
  2717.             (dun-mprincl "\nLogin failed."))
  2718.         (if dun-batch-mode
  2719.            (dun-mprincl 
  2720.             "Guest login okay, user access restrictions apply.")
  2721.           (dun-mprincl 
  2722.            "\nGuest login okay, user access restrictions apply."))
  2723.         (dun-ftp-commands)
  2724.         (setq newlist 
  2725. '("What password did you use during anonymous ftp to gamma?"))
  2726.         (setq newlist (append newlist (list ident)))
  2727.         (rplaca (nthcdr 1 dun-endgame-questions) newlist)))))))))
  2728.   
  2729. (defun dun-ftp-commands ()
  2730.     (setq dun-exitf nil)
  2731.     (let (line)
  2732.       (while (not dun-exitf)
  2733.     (dun-mprinc "ftp> ")
  2734.     (setq line (dun-read-line))
  2735.     (if 
  2736.         (eq
  2737.          (dun-parse2 nil 
  2738.             '((type . dun-ftptype) (binary . dun-bin) (bin . dun-bin)
  2739.               (send . dun-send) (put . dun-send) (quit . dun-ftpquit)
  2740.               (help . dun-ftphelp)(ascii . dun-fascii)
  2741.               ) line)
  2742.          -1)
  2743.         (dun-mprincl "No such command.  Try help.")))
  2744.       (setq dun-ftptype 'ascii)))
  2745.  
  2746. (defun dun-ftptype (args)
  2747.   (if (not (car args))
  2748.       (dun-mprincl "Usage: type [binary | ascii]")
  2749.     (setq args (intern (car args)))
  2750.     (if (eq args 'binary)
  2751.     (dun-bin nil)
  2752.       (if (eq args 'ascii)
  2753.       (dun-fascii 'nil)
  2754.     (dun-mprincl "Unknown type.")))))
  2755.  
  2756. (defun dun-bin (args)
  2757.   (dun-mprincl "Type set to binary.")
  2758.   (setq dun-ftptype 'binary))
  2759.  
  2760. (defun dun-fascii (args)
  2761.   (dun-mprincl "Type set to ascii.")
  2762.   (setq dun-ftptype 'ascii))
  2763.  
  2764. (defun dun-ftpquit (args)
  2765.   (setq dun-exitf t))
  2766.  
  2767. (defun dun-send (args)
  2768.   (if (not (car args))
  2769.       (dun-mprincl "Usage: send <filename>")
  2770.     (setq args (car args))
  2771.     (let (counter foo)
  2772.       (setq foo nil)
  2773.       (setq counter 0)
  2774.  
  2775. ;;; User can send commands!  Stupid user.
  2776.  
  2777.  
  2778.       (if (assq (intern args) dun-unix-verbs)
  2779.       (progn
  2780.         (rplaca (assq (intern args) dun-unix-verbs) 'IMPOSSIBLE)
  2781.         (dun-mprinc "Sending ")
  2782.         (dun-mprinc dun-ftptype)
  2783.         (dun-mprinc " file for ")
  2784.         (dun-mprincl args)
  2785.         (dun-mprincl "Transfer complete."))
  2786.  
  2787.     (dolist (x dun-objfiles)
  2788.       (if (string= args x)
  2789.           (progn
  2790.         (if (not (member counter dun-inventory))
  2791.             (progn
  2792.               (dun-mprincl "No such file.")
  2793.               (setq foo t))
  2794.           (dun-mprinc "Sending ")
  2795.           (dun-mprinc dun-ftptype)
  2796.           (dun-mprinc " file for ")
  2797.           (dun-mprinc (downcase (cadr (nth counter dun-objects))))
  2798.           (dun-mprincl ", (0 bytes)")
  2799.           (if (not (eq dun-ftptype 'binary))
  2800.               (progn
  2801.             (if (not (member obj-protoplasm
  2802.                      (nth receiving-room 
  2803.                           dun-room-objects)))
  2804.                 (dun-replace dun-room-objects receiving-room
  2805.                      (append (nth receiving-room 
  2806.                           dun-room-objects)
  2807.                          (list obj-protoplasm))))
  2808.             (dun-remove-obj-from-inven counter))
  2809.             (dun-remove-obj-from-inven counter)
  2810.             (dun-replace dun-room-objects receiving-room
  2811.                  (append (nth receiving-room dun-room-objects)
  2812.                      (list counter))))
  2813.           (setq foo t)
  2814.           (dun-mprincl "Transfer complete."))))
  2815.       (setq counter (+ 1 counter)))
  2816.     (if (not foo)
  2817.         (dun-mprincl "No such file."))))))
  2818.  
  2819. (defun dun-ftphelp (args)
  2820.   (dun-mprincl 
  2821.    "Possible commands are:\nsend    quit    type   ascii  binary   help"))
  2822.  
  2823. (defun dun-uexit (args)
  2824.   (setq dungeon-mode 'dungeon)
  2825.   (dun-mprincl "\nYou step back from the console.")
  2826.   (define-key dungeon-mode-map "\r" 'dun-parse)
  2827.   (if (not dun-batch-mode)
  2828.       (dun-messages)))
  2829.  
  2830. (defun dun-pwd (args)
  2831.   (dun-mprincl dun-cdpath))
  2832.  
  2833. (defun dun-uncompress (args)
  2834.   (if (not (car args))
  2835.       (dun-mprincl "Usage: uncompress <filename>")
  2836.     (setq args (car args))
  2837.     (if (or dun-uncompressed
  2838.         (and (not (string= args "paper.o"))
  2839.          (not (string= args "paper.o.z"))))
  2840.     (dun-mprincl "Uncompress command failed.")
  2841.       (setq dun-uncompressed t)
  2842.       (setq dun-inventory (append dun-inventory (list obj-paper))))))
  2843.  
  2844. (defun dun-rlogin (args)
  2845.   (let (passwd)
  2846.     (if (not (car args))
  2847.     (dun-mprincl "Usage: rlogin <hostname>")
  2848.       (setq args (car args))
  2849.       (if (string= args "endgame")
  2850.       (dun-rlogin-endgame)
  2851.     (if (not (string= args "gamma"))
  2852.         (dun-mprincl "No such host.")
  2853.       (if (not dun-ethernet)
  2854.           (dun-mprincl "Host not responding.")
  2855.         (dun-mprinc "Password: ")
  2856.         (setq passwd (dun-read-line))
  2857.         (if (not (string= passwd "worms"))
  2858.         (dun-mprincl "\nlogin incorrect")
  2859.           (dun-mprinc 
  2860. "\nYou begin to feel strange for a moment, and you lose your items."
  2861. )
  2862.           (dun-replace dun-room-objects computer-room 
  2863.                (append (nth computer-room dun-room-objects) 
  2864.                    dun-inventory))
  2865.           (setq dun-inventory nil)
  2866.           (setq dun-current-room receiving-room)
  2867.           (dun-uexit nil))))))))
  2868.   
  2869. (defun dun-cd (args)
  2870.   (let (tcdpath tcdroom path-elemants room-check)
  2871.     (if (not (car args))
  2872.     (dun-mprincl "Usage: cd <path>")
  2873.       (setq tcdpath dun-cdpath)
  2874.       (setq tcdroom dun-cdroom)
  2875.       (setq dun-badcd nil)
  2876.       (condition-case nil
  2877.       (setq path-elements (dun-get-path (car args) nil))
  2878.     (error (dun-mprincl "Invalid path.")
  2879.            (setq dun-badcd t)))
  2880.       (dolist (pe path-elements)
  2881.           (unless dun-badcd
  2882.               (if (not (string= pe "."))
  2883.               (if (string= pe "..")
  2884.                   (progn
  2885.                 (if (> tcdroom 0)                  ;In a room
  2886.                     (progn
  2887.                       (setq tcdpath "/rooms")
  2888.                       (setq tcdroom -2))
  2889.                     ;In /rooms,/usr,root
  2890.                   (if (or 
  2891.                        (= tcdroom -2) (= tcdroom -4) 
  2892.                        (= tcdroom -3))
  2893.                       (progn
  2894.                     (setq tcdpath "/")
  2895.                     (setq tcdroom -3))
  2896.                     (if (= tcdroom -10)       ;In /usr/toukmond
  2897.                     (progn
  2898.                       (setq tcdpath "/usr")
  2899.                       (setq tcdroom -4))))))
  2900.                 (if (string= pe "/")
  2901.                 (progn
  2902.                   (setq tcdpath "/")
  2903.                   (setq tcdroom -3))
  2904.                   (if (= tcdroom -4)
  2905.                   (if (string= pe "toukmond")
  2906.                       (progn
  2907.                     (setq tcdpath "/usr/toukmond")
  2908.                     (setq tcdroom -10))
  2909.                     (dun-nosuchdir))
  2910.                 (if (= tcdroom -10)
  2911.                     (dun-nosuchdir)
  2912.                   (if (> tcdroom 0)
  2913.                       (dun-nosuchdir)
  2914.                     (if (= tcdroom -3)
  2915.                     (progn
  2916.                       (if (string= pe "rooms")
  2917.                           (progn
  2918.                         (setq tcdpath "/rooms")
  2919.                         (setq tcdroom -2))
  2920.                         (if (string= pe "usr")
  2921.                         (progn
  2922.                           (setq tcdpath "/usr")
  2923.                           (setq tcdroom -4))
  2924.                           (dun-nosuchdir))))
  2925.                       (if (= tcdroom -2)
  2926.                       (progn
  2927.                         (dolist (x dun-visited)
  2928.                             (setq room-check 
  2929.                               (nth x 
  2930.                                   dun-room-shorts))
  2931.                             (if (string= room-check pe)
  2932.                             (progn
  2933.                               (setq tcdpath 
  2934.                          (concat "/rooms/" room-check))
  2935.                               (setq tcdroom x))))
  2936.                         (if (= tcdroom -2)
  2937.                         (dun-nosuchdir)))))))))))))
  2938.       (if (not dun-badcd)
  2939.       (progn
  2940.         (setq dun-cdpath tcdpath)
  2941.         (setq dun-cdroom tcdroom)
  2942.         0)
  2943.       -2))))
  2944.  
  2945. (defun dun-nosuchdir ()
  2946.   (dun-mprincl "No such directory.")
  2947.   (setq dun-badcd t))
  2948.  
  2949. (defun dun-cat (args)
  2950.   (let (doto checklist)
  2951.     (if (not (setq args (car args)))
  2952.     (dun-mprincl "Usage: cat <ascii-file-name>")
  2953.       (if (string-match "/" args)
  2954.       (dun-mprincl "cat: only files in current directory allowed.")
  2955.     (if (and (> dun-cdroom 0) (string= args "description"))
  2956.         (dun-mprincl (car (nth dun-cdroom dun-rooms)))
  2957.       (if (setq doto (string-match "\\.o" args))
  2958.           (progn
  2959.         (if (= dun-cdroom -10)
  2960.             (setq checklist dun-inventory)
  2961.           (setq checklist (nth dun-cdroom dun-room-objects)))
  2962.         (if (not (member (cdr 
  2963.                   (assq (intern 
  2964.                      (substring args 0 doto)) 
  2965.                     dun-objnames))
  2966.                  checklist))
  2967.             (dun-mprincl "File not found.")
  2968.           (dun-mprincl "Ascii files only.")))
  2969.         (if (assq (intern args) dun-unix-verbs)
  2970.         (dun-mprincl "Ascii files only.")
  2971.           (dun-mprincl "File not found."))))))))
  2972.   
  2973. (defun dun-zippy (args)
  2974.   (dun-mprincl (yow)))
  2975.  
  2976. (defun dun-rlogin-endgame ()
  2977.   (if (not (= (dun-score nil) 90))
  2978.       (dun-mprincl 
  2979.        "You have not achieved enough points to connect to endgame.")
  2980.     (dun-mprincl"\nWelcome to the endgame.  You are a truly noble adventurer.")
  2981.     (setq dun-current-room treasure-room)
  2982.     (setq dun-endgame t)
  2983.     (dun-replace dun-room-objects endgame-treasure-room (list obj-bill))
  2984.     (dun-uexit nil)))
  2985.  
  2986.  
  2987. (random t)
  2988. (setq tloc (+ 60 (% (abs (random)) 18)))
  2989. (dun-replace dun-room-objects tloc 
  2990.          (append (nth tloc dun-room-objects) (list 18)))
  2991.  
  2992. (setq tcomb (+ 100 (% (abs (random)) 899)))
  2993. (setq dun-combination (prin1-to-string tcomb))
  2994.  
  2995. ;;;;
  2996. ;;;; This section defines the DOS emulation functions for dunnet
  2997. ;;;;
  2998.  
  2999. (defun dun-dos-parse (args)
  3000.   (interactive "*p")
  3001.   (beginning-of-line)
  3002.   (let (beg)
  3003.     (setq beg (+ (point) 3))
  3004.     (end-of-line)
  3005.     (if (not (= beg (point)))
  3006.     (let (line)
  3007.       (setq line (downcase (buffer-substring beg (point))))
  3008.       (princ line)
  3009.       (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
  3010.           (progn
  3011.         (sleep-for 1)
  3012.         (dun-mprincl "Bad command or file name"))))
  3013.       (goto-char (point-max))
  3014.       (dun-mprinc "\n"))
  3015.     (if (eq dungeon-mode 'dos)
  3016.     (progn
  3017.       (dun-fix-screen)
  3018.       (dun-dos-prompt)))))
  3019.  
  3020. (defun dun-dos-interface ()
  3021.   (dun-dos-boot-msg)
  3022.   (setq dungeon-mode 'dos)
  3023.   (define-key dungeon-mode-map "\r" 'dun-dos-parse)
  3024.   (dun-dos-prompt))
  3025.  
  3026. (defun dun-dos-type (args)
  3027.   (sleep-for 2)
  3028.   (if (setq args (car args))
  3029.       (if (string= args "foo.txt")
  3030.       (dun-dos-show-combination)
  3031.     (if (string= args "command.com")
  3032.         (dun-mprincl "Cannot type binary files")
  3033.       (dun-mprinc "File not found - ")
  3034.       (dun-mprincl (upcase args))))
  3035.     (dun-mprincl "Must supply file name")))
  3036.  
  3037. (defun dun-dos-invd (args)
  3038.   (sleep-for 1)
  3039.   (dun-mprincl "Invalid drive specification"))
  3040.  
  3041. (defun dun-dos-dir (args)
  3042.   (sleep-for 1)
  3043.   (if (or (not (setq args (car args))) (string= args "\\"))
  3044.       (dun-mprincl "
  3045.  Volume in drive A is FOO        
  3046.  Volume Serial Number is 1A16-08C9
  3047.  Directory of A:\\
  3048.  
  3049. COMMAND  COM     47845 04-09-91   2:00a
  3050. FOO      TXT        40 01-20-93   1:01a
  3051.         2 file(s)      47845 bytes
  3052.                      1065280 bytes free
  3053. ")
  3054.     (dun-mprincl "
  3055.  Volume in drive A is FOO        
  3056.  Volume Serial Number is 1A16-08C9
  3057.  Directory of A:\\
  3058.  
  3059. File not found")))
  3060.  
  3061.  
  3062. (defun dun-dos-prompt ()
  3063.   (dun-mprinc "A> "))
  3064.  
  3065. (defun dun-dos-boot-msg ()
  3066.   (sleep-for 3)
  3067.   (dun-mprinc "Current time is ")
  3068.   (dun-mprincl (substring (current-time-string) 12 20))
  3069.   (dun-mprinc "Enter new time: ")
  3070.   (dun-read-line)
  3071.   (if (not dun-batch-mode)
  3072.       (dun-mprinc "\n")))
  3073.  
  3074. (defun dun-dos-spawn (args)
  3075.   (sleep-for 1)
  3076.   (dun-mprincl "Cannot spawn subshell"))
  3077.  
  3078. (defun dun-dos-exit (args)
  3079.   (setq dungeon-mode 'dungeon)
  3080.   (dun-mprincl "\nYou power down the machine and step back.")
  3081.   (define-key dungeon-mode-map "\r" 'dun-parse)
  3082.   (if (not dun-batch-mode)
  3083.       (dun-messages)))
  3084.  
  3085. (defun dun-dos-no-disk ()
  3086.   (sleep-for 3)
  3087.   (dun-mprincl "Boot sector not found"))
  3088.  
  3089.  
  3090. (defun dun-dos-show-combination ()
  3091.   (sleep-for 2)
  3092.   (dun-mprinc "\nThe combination is ")
  3093.   (dun-mprinc dun-combination)
  3094.   (dun-mprinc ".\n"))
  3095.  
  3096. (defun dun-dos-nil (args))
  3097.  
  3098.  
  3099. ;;;;
  3100. ;;;; This section defines the save and restore game functions for dunnet.
  3101. ;;;;
  3102.  
  3103. (defun dun-save-game (filename)
  3104.   (if (not (setq filename (car filename)))
  3105.       (dun-mprincl "You must supply a filename for the save.")
  3106.     (if (file-exists-p filename)
  3107.     (delete-file filename))
  3108.     (setq dun-numsaves (1+ dun-numsaves))
  3109.     (dun-make-save-buffer)
  3110.     (dun-save-val "dun-current-room")
  3111.     (dun-save-val "dun-computer")
  3112.     (dun-save-val "dun-combination")
  3113.     (dun-save-val "dun-visited")
  3114.     (dun-save-val "dun-diggables")
  3115.     (dun-save-val "dun-key-level")
  3116.     (dun-save-val "dun-floppy")
  3117.     (dun-save-val "dun-numsaves")
  3118.     (dun-save-val "dun-numcmds")
  3119.     (dun-save-val "dun-logged-in")
  3120.     (dun-save-val "dungeon-mode")
  3121.     (dun-save-val "dun-jar")
  3122.     (dun-save-val "dun-lastdir")
  3123.     (dun-save-val "dun-black")
  3124.     (dun-save-val "dun-nomail")
  3125.     (dun-save-val "dun-unix-verbs")
  3126.     (dun-save-val "dun-hole")
  3127.     (dun-save-val "dun-uncompressed")
  3128.     (dun-save-val "dun-ethernet")
  3129.     (dun-save-val "dun-sauna-level")
  3130.     (dun-save-val "dun-room-objects")
  3131.     (dun-save-val "dun-room-silents")
  3132.     (dun-save-val "dun-inventory")
  3133.     (dun-save-val "dun-endgame-question")
  3134.     (dun-save-val "dun-endgame")
  3135.     (dun-save-val "dun-cdroom")
  3136.     (dun-save-val "dun-cdpath")
  3137.     (dun-save-val "dun-correct-answer")
  3138.     (dun-save-val "dun-inbus")
  3139.     (if (dun-compile-save-out filename)
  3140.     (dun-mprincl "Error saving to file.")
  3141.       (dun-do-logfile 'save nil)
  3142.       (switch-to-buffer "*dungeon*")
  3143.       (princ "")
  3144.       (dun-mprincl "Done."))))
  3145.  
  3146. (defun dun-make-save-buffer ()
  3147.   (switch-to-buffer (get-buffer-create "*save-dungeon*"))
  3148.   (erase-buffer))
  3149.  
  3150. (defun dun-compile-save-out (filename)
  3151.   (let (ferror)
  3152.     (setq ferror nil)
  3153.     (condition-case nil
  3154.     (dun-rot13)
  3155.       (error (setq ferror t)))
  3156.     (if (not ferror)
  3157.     (progn
  3158.       (goto-char (point-min))))
  3159.     (condition-case nil
  3160.         (write-region 1 (point-max) filename nil 1)
  3161.         (error (setq ferror t)))
  3162.     (kill-buffer (current-buffer))
  3163.     ferror))
  3164.     
  3165.  
  3166. (defun dun-save-val (varname)
  3167.   (let (value)
  3168.     (setq varname (intern varname))
  3169.     (setq value (eval varname))
  3170.     (dun-minsert "(setq ")
  3171.     (dun-minsert varname)
  3172.     (dun-minsert " ")
  3173.     (if (or (listp value)
  3174.         (symbolp value))
  3175.     (dun-minsert "'"))
  3176.     (if (stringp value)
  3177.     (dun-minsert "\""))
  3178.     (dun-minsert value)
  3179.     (if (stringp value)
  3180.     (dun-minsert "\""))
  3181.     (dun-minsertl ")")))
  3182.  
  3183.  
  3184. (defun dun-restore (args)
  3185.   (let (file)
  3186.     (if (not (setq file (car args)))
  3187.     (dun-mprincl "You must supply a filename.")
  3188.       (if (not (dun-load-d file))
  3189.       (dun-mprincl "Could not load restore file.")
  3190.     (dun-mprincl "Done.")
  3191.     (setq room 0)))))
  3192.  
  3193.  
  3194. (defun dun-do-logfile (type how)
  3195.   (let (ferror newscore)
  3196.     (setq ferror nil)
  3197.     (switch-to-buffer (get-buffer-create "*score*"))
  3198.     (erase-buffer)
  3199.     (condition-case nil
  3200.     (insert-file-contents dun-log-file)
  3201.       (error (setq ferror t)))
  3202.     (unless ferror
  3203.         (goto-char (point-max))
  3204.         (dun-minsert (current-time-string))
  3205.         (dun-minsert " ")
  3206.         (dun-minsert (user-login-name))
  3207.         (dun-minsert " ")
  3208.         (if (eq type 'save)
  3209.         (dun-minsert "saved ")
  3210.           (if (= (dun-endgame-score) 110)
  3211.           (dun-minsert "won ")
  3212.         (if (not how)
  3213.             (dun-minsert "quit ")
  3214.           (dun-minsert "killed by ")
  3215.           (dun-minsert how)
  3216.           (dun-minsert " "))))
  3217.         (dun-minsert "at ")
  3218.         (dun-minsert (cadr (nth (abs room) dun-rooms)))
  3219.         (dun-minsert ". score: ")
  3220.         (if (> (dun-endgame-score) 0)
  3221.         (dun-minsert (setq newscore (+ 90 (dun-endgame-score))))
  3222.           (dun-minsert (setq newscore (dun-reg-score))))
  3223.         (dun-minsert " saves: ")
  3224.         (dun-minsert dun-numsaves)
  3225.         (dun-minsert " commands: ")
  3226.         (dun-minsert dun-numcmds)
  3227.         (dun-minsert "\n")
  3228.         (write-region 1 (point-max) dun-log-file nil 1))
  3229.     (kill-buffer (current-buffer))))
  3230.  
  3231.  
  3232. ;;;;
  3233. ;;;; These are functions, and function re-definitions so that dungeon can
  3234. ;;;; be run in batch mode.
  3235.  
  3236.  
  3237. (defun dun-batch-mprinc (arg)
  3238.    (if (stringp arg)
  3239.        (send-string-to-terminal arg)
  3240.      (send-string-to-terminal (prin1-to-string arg))))
  3241.  
  3242.  
  3243. (defun dun-batch-mprincl (arg)
  3244.    (if (stringp arg)
  3245.        (progn
  3246.            (send-string-to-terminal arg)
  3247.            (send-string-to-terminal "\n"))
  3248.      (send-string-to-terminal (prin1-to-string arg))
  3249.      (send-string-to-terminal "\n")))
  3250.  
  3251. (defun dun-batch-parse (dun-ignore dun-verblist line)
  3252.   (setq line-list (dun-listify-string (concat line " ")))
  3253.   (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
  3254.  
  3255. (defun dun-batch-parse2 (dun-ignore dun-verblist line)
  3256.   (setq line-list (dun-listify-string2 (concat line " ")))
  3257.   (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
  3258.  
  3259. (defun dun-batch-read-line ()
  3260.   (read-from-minibuffer "" nil dungeon-batch-map))
  3261.  
  3262.  
  3263. (defun dun-batch-loop ()
  3264.   (setq dun-dead nil)
  3265.   (setq room 0)
  3266.   (while (not dun-dead)
  3267.     (if (eq dungeon-mode 'dungeon)
  3268.     (progn
  3269.       (if (not (= room dun-current-room))
  3270.           (progn
  3271.         (dun-describe-room dun-current-room)
  3272.         (setq room dun-current-room)))
  3273.       (dun-mprinc ">")
  3274.       (setq line (downcase (dun-read-line)))
  3275.       (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
  3276.           (dun-mprinc "I don't understand that.\n"))))))
  3277.  
  3278. (defun dun-batch-dos-interface ()
  3279.   (dun-dos-boot-msg)
  3280.   (setq dungeon-mode 'dos)
  3281.   (while (eq dungeon-mode 'dos)
  3282.     (dun-dos-prompt)
  3283.     (setq line (downcase (dun-read-line)))
  3284.     (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
  3285.     (progn
  3286.       (sleep-for 1)
  3287.       (dun-mprincl "Bad command or file name"))))
  3288.   (goto-char (point-max))
  3289.   (dun-mprinc "\n"))
  3290.  
  3291. (defun dun-batch-unix-interface ()
  3292.     (dun-login)
  3293.     (if dun-logged-in
  3294.     (progn
  3295.       (setq dungeon-mode 'unix)
  3296.       (while (eq dungeon-mode 'unix)
  3297.         (dun-mprinc "$ ")
  3298.         (setq line (downcase (dun-read-line)))
  3299.         (if (eq (dun-parse2 nil dun-unix-verbs line) -1)
  3300.         (let (esign)
  3301.           (if (setq esign (string-match "=" line))
  3302.               (dun-doassign line esign)        
  3303.             (dun-mprinc (car line-list))
  3304.             (dun-mprincl ": not found.")))))
  3305.       (goto-char (point-max))
  3306.       (dun-mprinc "\n"))))
  3307.  
  3308. (defun dungeon-nil (arg)
  3309.   "noop"
  3310.   (interactive "*p"))
  3311.  
  3312. (defun dun-batch-dungeon ()
  3313.   (load "dun-batch")
  3314.   (setq dun-visited '(27))
  3315.   (dun-mprinc "\n")
  3316.   (dun-batch-loop))
  3317.  
  3318. (unless (not noninteractive)
  3319.   (fset 'dun-mprinc 'dun-batch-mprinc)
  3320.   (fset 'dun-mprincl 'dun-batch-mprincl)
  3321.   (fset 'dun-vparse 'dun-batch-parse)
  3322.   (fset 'dun-parse2 'dun-batch-parse2)
  3323.   (fset 'dun-read-line 'dun-batch-read-line)
  3324.   (fset 'dun-dos-interface 'dun-batch-dos-interface)
  3325.   (fset 'dun-unix-interface 'dun-batch-unix-interface)
  3326.   (dun-mprinc "\n")
  3327.   (setq dun-batch-mode t)
  3328.   (dun-batch-loop))
  3329.